Re: SimpleXML: DOM, SAX or Other?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phpdiscuss - Php Newsgroups And Mailing Lists wrote:

> Hi,
> 
> Does anybody have any depthful knowledge of the SimpleXML extension in
> PHP5?..
> 
> More accurately, do you know if the simpleXml->xpath() method uses DOM,
> SAX or some other method of parsing a loaded XML document?
> 
> I ask because I am trying to parse arbitrary XML documents as efficiently
> as possible (avoiding DOM).
> 
> Kieran

Hi,

I've recently done a fair bit of work trying to make sense (for me) of the
various PHP 5 XML-related alternatives.

The bottom line (for me) is that at the end of the day the DOM functions
provide the most access and flexibility, although at the cost of slightly
more design complexity.  If I have to generate a new XML file, DOM (for me)
is the way to go.

The XML Parser found its home (for me) processing include files.  The output
of this process is a single XML file that I can feed into downstream
processes.

The SimpleXML routines found its home (for me) working with static XML
files.  I haven't figured out how to add elements to a SimpleXML object, so
it tends to be limited to "read-only" applications.

The SimpleXMLIterator found a home (for me) in creating ID's and node
genelogical ID's.  Oddly, the SimpleXMLIterator skips the root level xml
element and I had to use DOM to "add it back".

I ended up creating "wrappers" and "proxy" classes for each of the above. 
This allowed me to gain some uniformity in my API's so  tend to forget
about what's happening underneath.

I also ended up creating a DomXPathQueryManager class to hide some of the
complexity in setting up and executing XPath queries.

So, at the end of the day, I might use any or all in some combination, but
know that the DOM functions are my backup that can do it all.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux