Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- getElementById in PHP5
October 30, 2006, 12:45 pm
rate this thread
I am working on PHP5 and all the xmldom related extensions are
installed and on properly.
I am trying to execute following code but some how not working.
$doc = new DomDocument();
$doc->validateOnParse = true;
//xml file contains one element with this id
$elem = $doc->getElementById( 'eee' );
echo "<br>IT IS NULL";
echo "<br>NOT NULL.";
The output shows me null every time...
Why is that?????
Thanks in advance
Re: getElementById in PHP5
The manual hints towards why:
"According to the DOM standard this requires a DTD which defines the attribute
ID to be of type ID. You need to validate your document with
DOMDocument->validate() or DOMDocument->validateOnParse before using this
You've set validateOnParse, but you haven't posted the contents of abc.xml.
Does it include a DTD that defines ID?
There is a link in the user contributed notes to the following site that
Andy Hassall :: firstname.lastname@example.org :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool