Re: Good XML Parser

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

 



2008/5/12 Waynn Lue <waynnlue@xxxxxxxxx>:
> What's the best way to pull down XML from a URL?  fopen($URL), then
> using xml_parse?  Or should I be using XML_Parser or SimpleXML?

XML parsers fall into two general camps - DOM and SAX. DOM parsers
represent an entire XML document as a tree, in-memory, when they are
first instantiated. They are generally more memory-hungry and take
longer to instantiate, but they can answer queries like "what is the
path to this node" or "give me the siblings of this node".

SAX parsers are stream- or event-based, and are much more lightweight
- they parse the XML in a JIT fashion, and can't answer much more than
"give me the next node".

If you just need the data, a SAX parser will probably do everything
you need. If you need the tree structure implicit in an XML document,
use a DOM parser. Expat, which XML Parser
(http://uk3.php.net/manual/en/book.xml.php) is based on, is a SAX
parser. DOM XML (http://uk3.php.net/manual/en/book.domxml.php) is,
obviously, a DOM parser. I don't know, off the top of my head, which
camp SimpleXML falls into.

-- 
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