PHP problem with DOM parsing

vBFan

New Member
The code pasted below, works on my PC, but not on my hosting (which have PHP 5.2.13 installed).\[code\]$source = file_get_contents('http://example.com/example', 0);$dom = new DOMDocument;@$dom->loadHTML($source);$dom->preserveWhiteSpace = false;$xpath = new DOMXPath($dom);$tags = $xpath->query('//div[@class="item"]');$xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\r\n<root>\r\n";foreach($tags as $tag) $xml .= "\t<tag>" . trim($tag->nodeValue) . "</tag>\r\n";$xml .= '</root>';$xml_file = 'tags.xml';$fopen_handle = fopen($xml_file, 'w+');fwrite($fopen_handle, $xml);fclose($fopen_handle);\[/code\]On my hosting, the foreach loop doesn't executes i.e. I get only this in the XML:\[code\]<?xml version="1.0" encoding="UTF-8"?><root></root>\[/code\]Thanks in advance.
 
Back
Top