CData 字符串未完成


CData string unfinished?

我有一个脚本来解析产品的XML文件,但我似乎无法掌握解析它的窍门。我有代码:

$file = $shop_path.'datafeeds/MC-B01.xml';
$xml = simplexml_load_file($file, null, LIBXML_NOCDATA);
$items = $xml->Items;
for($i = 0; $i < 17000; $i++) {
    $name = $items[$i]->Product_Name;
    echo $name.'<br />';
}

但是,我得到了各种奇怪的错误:

PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ./../datafeeds/MC-B01.xml:172439: parser error : CData section not finished
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ons&#44; in or out of the water. Cleanup is a snap after the fun with Pipedream
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ^
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ./../datafeeds/MC-B01.xml:172439: parser error : PCDATA invalid Char value 3
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ons&#44; in or out of the water. Cleanup is a snap after the fun with Pipedream 
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ^
PHP Warning: in file C:/xampp/htdocs/trow/tools/rip.php on line 188: simplexml_load_file() [function.simplexml-load-file]: ./../datafeeds/MC-B01.xml:172439: parser error : Sequence ']]>' not allowed in content

奇怪的部分是,包含错误显示的文本的CData块似乎是一个格式正确的块。(我不能在这里发布它,因为它是成年人的性质。

有什么建议吗?

CDATA并不意味着你可以输入任何东西,这意味着可能会与标记符号混淆的事情可以被解析器忽略。因此,CDATA 中的字符必须包含除制表符、CR、LF 或特殊 FFFE、FFFF 字符之外的一些控制字符。删除它们,您将拥有明亮的一天!

您应该尝试将该文档保存为工作站上的本地xml文件,然后在Internet Explorer或Firefox浏览器中打开它(或可以解析和验证XML文档的东西)以及您需要修复的任何错误。

对我来说,它

看起来像是一些非标准字符,它通过介于两者之间使您的 CDATA 部分不完整。