I have a script to parse an XML file of products, but I can't seem to get the hang of parsing it. I have the code:
$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 />';
}
However i get all kinds of strange errors thrown:
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, 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, 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
The strange part is that the CData block that contains the text the errors show seems to be a correctly formed block. (I can't post it here because of it's adult nature.)
Any suggestions?