Recently I got from here about how to parse large xml files using of XMLReader and SimpleXML in PHP. I tried to adapt the code of above mentioned tutorial into my php procedure like this:
$xml_url = "http://localhost/rest/server.php?wstoken=".$token&function=contents";
$reader = new XMLReader;
$reader->open($xml_url);
while($reader->read()){
if($reader->nodeType == XMLReader::ELEMENT && $reader->name == 'SINGLE'){
$doc = new DOMDocument('1.0','UTF-8');
$xml = simplexml_import_dom($doc->importNode($reader->expand(), true));
//$titleString = (string) $xml->description;
echo $xml->description;
}
}
The XML file called via url is so (the xml version is here):
Other SINGLE tags (marked with 'red') have the same structure and I want to print 'description' of them also.
The output is with above mentioned php procedure is: error on line 1 at column 1: Extra content at the end of the document. Any help would be great.