I'm trying to parse a xml file using DOMXPath class in PHP but I get some errors when I do queries. My XML have something like this
XML
<?xml version="1.0" encoding="UTF-8"?>
<news><new><title><!CDATA[bla bla bla]]></title><content><!CDATA[<p>bla bla bla</p>]]></content></new></news>
DOMXPath
$xml = new DOMDocument();
$xml->load( $filename );
$xpath = new DOMXPath( $xml );
$news = $xpath->query('//news');
The $news length is always 0, and news tag exists in xml file.
What am I doing wrong?
Best regards,
Ismael.
Check this :
I have modified some of your code :
I am getting length value
1
book.xml