Re: Working with XML: DomDocument or SimpleXML?

From: Date: Fri, 21 Sep 2007 13:12:07 +0000
Subject: Re: Working with XML: DomDocument or SimpleXML?
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-262337@lists.php.net to get a copy of this message
Colin Guthrie wrote:
Rob wrote:
if ($xml instanceof SimpleXMLElement) { /* No copying, just use the existing XML tree directly */ $node = dom_import_simplexml($xml); return $node->ownerDocument; }
Yeah I had that initially too but that did not produce a DOMDocument Object but a DOMNode Object (or something like that.... will have to test again as memory is corrupted - there /was/ a reason, and stupid me didn't comment the code.....).
It had to have been for some other reason as the return type for the above example is a DOMDocument. A raw DOMNode is *NEVER* returned from the DOM extension. It is simply a base class for most of the DOM classes, such as DOMDocument. Rob

« previous php.general (#262337) next »