CData部分没有完成问题 [英] CData section not finished problem

查看:188
本文介绍了CData部分没有完成问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我对我的XML使用DOMDocument :: loadXML()时,我得到错误:

When I use DOMDocument::loadXML() for my XML below I get error:

Warning: DOMDocument::loadXML() [domdocument.loadxml]: CData section not finished http://www.site.org/displayimage.php?album=se in Entity,
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Premature end of data in tag image line 7 in Entity
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Premature end of data in tag quizz line 3 in Entity
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Premature end of data in tag quizzes line 2 in Entity
Fatal error: Call to a member function getElementsByTagName() on a non-object 

在我看来,我的CData部分已关闭,但仍然收到此错误。 XML如下所示:

It seems to me that my CData sections are closed but still I get this error. XML looks like this:

<?xml version="1.0" encoding="utf-8"?>
<quizzes>
<quizz>
<title><![CDATA[Title]]></title>
<descr><![CDATA[Some text here!]]></descr>
<tags><![CDATA[one tag, second tag]]></tags>
<image><![CDATA[http://www.site.org/displayimage.php?album=search&cat=0&pos=1]]></image>
<results>
<result>
<title><![CDATA[Something]]></title>
<descr><![CDATA[Some text here]]></descr>
<image><![CDATA[http://www.site.org/displayimage.php?album=search&cat=0&pos=17]]></image>
<id>1</id>
</result>
</results>
</quizz>
</quizzes>

你能帮我看看有什么问题吗?

Could you help me discover what is the problem?

推荐答案

我发现问题在于使用cURL将这个XML传递给PHP。我把它作为普通文本发送,&这个XML中的char被解释为下一个参数的分隔符。所以当我逃脱这个字符它开始正常工作。

I 've found that the problem was with passing this XML in PHP with cURL. I've sent it as normal text, and & char in this XML was interpreted as delimiter to next parameter. So when I escaped this char it started to work properly.

这篇关于CData部分没有完成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆