Re: Is really no one interested?
| From: | Rob Richards | Date: | Tue, 01 Nov 2005 11:35:14 +0000 |
| Subject: | Re: Is really no one interested? | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-19881@lists.php.net to get a copy of this message | ||
Marian Kostadinov wrote:
//But how can I understand what is the name of the root node? $dom_sxe = dom_import_simplexml($sxe1); //Hooray, we've got node name echo $dom_sxe->nodeName; //And what happens if element sequence changes? . echo $dom_sxe->childNodes->item(1)->firstChild->firstChild->firstChild->nodeValue; //... hm... I prefer SimpleXML. The API is to be kept simple and what you are asking for can be done extending the SimpleXMLElement and the functions are a whole 1 line of user code:<?php class cNode extends SimpleXMLElement { function getName() {
return dom_import_simplexml($this)->nodeName;} function getType() {
return dom_import_simplexml($this)->nodeType;} } $xml = '<root />'; $sxe = simplexml_load_string($xml, 'cNode'); print $sxe->getName()."\n"; print $sxe->getType()."\n"; ?> Of course XPath could be used in place of DOM too though. Rob