Is XMLReader a SAX parser, a DOM parser, or neither?

Posted by Renesis on Stack Overflow See other posts from Stack Overflow or by Renesis
Published on 2010-06-15T19:40:42Z Indexed on 2010/06/15 19:52 UTC
Read the original article Hit count: 292

Filed under:
|
|
|
|

I am testing various methods to read (possibly large, and very often) XML configuration files in PHP. No writing is ever needed. I have two successful implementations, one using SimpleXML (which I know is a DOM parser) and one using XMLReader.

I know that a DOM reader must read the whole tree and therefore uses more memory. My tests reflect that. I also know that A SAX parser is an "event-based" parser that uses less memory because it reads each node from the stream without checking what is next.

XMLReader also reads from a stream with the cursor providing data about the node it is currently at. So, it definitely sounds like XMLReader (http://us2.php.net/xmlreader) is not a DOM parser, but my question is, is it a SAX parser, or something else? It seems like XMLReader behaves the way a SAX parser does but does not throw the events themselves (in other words, can you construct a SAX parser with XMLReader?)

If it is something else, does the classification it's in have a name?

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml