Re: Working with XML: DomDocument or SimpleXML?

From: Date: Thu, 20 Sep 2007 20:36:08 +0000
Subject: Re: Working with XML: DomDocument or SimpleXML?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-262317@lists.php.net to get a copy of this message
Robert Cummings wrote: > I still use PHP4 so I wrote my own XML handling class that wraps the > xml_xxx() series of functions. Haven't had a problem with it. Makes > working with XML very easy since it uses a path string syntax to > focus/access nodes and attributes: Cheers for that. I know I definitely want to do XSLT stuff and for that I need to use DomDocument (I'm sure there are other ways but this works fine for me so far!). I guess think I asked too open a question, when really I'm looking for fairly specific answers (or rather opinions). I'll phrase it better: one can easily convert a SimpleXML object to a DomDocument[1], but nothing is "free" (in terms of time taken and memory requirements etc.), so really I guess I want to ask if the trade off of the simplicity of working with SimpleXML is worth it considering the overhead of the conversion process to a DomDocument for subsequent XSLT transforms etc? Col [1] e.g. if ($xml instanceof SimpleXMLElement) { $rv = new DOMDocument('1.0', 'utf-8'); $node = dom_import_simplexml($xml); $node = $rv->importNode($node, true); $rv->appendChild($node); return $rv; }

« previous php.general (#262317) next »