2

PHP not have a "standard SAX" interface for event-driven XML parse, have a Expat one. Expat require --enable-libxml option... But LibXML2 have a good and fast standard SAX interface (!)... So, how to access the LibXML2's standard SAX interface with PHP?

There are a simple workaround to enable the SAX interface?


Related question: Is XMLReader a SAX parser, a DOM parser, or neither?

Terminology (to say the "same language" in the discussions):

  • event-driven XML parser: SAX and Expat, they was 1998's "competidors", but today (2013's) are only a "reference model for interfacing the parser implementation".

  • event-driven XML parser implementations: see LibXML2, expat.sourceforge, Oracle/Java/SAX, etc. They are "concrete implementations" (can generate binary code for the parser).

  • SAX interface: an abstraction based on the "SAX reference model", see saxproject.org and Wikipedia.

  • Expat interface: an abstraction based on the "Expat reference model", see jclark.com/xml and Wikipedia.

  • PHP's XML Parser conventions for an event-driven XML parser interface... Is a Expat interface but, it is over the Expat or the LibXML2 implementation??

  • PHP's SAX interface: not exist (!), but can be build as more one LibXML2 interface?

  • PHP's "other XML parser interfaces": remember that DomDocument, XSLTProcessor, etc. are PHP interfaces to the LibXML2 implementations.

PS: please edit this text for better or detailed explanations... Detailing "library interface": is a set of function names, methods and properties, used as "module interface" between PHP (for programmers abstrations) and a library implementation (drivers, etc. for assembler/binary concrete implementation).

Community
  • 1
  • 1
Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • You are most likely looking for `XMLReader`. http://php.net/XMLReader – hakre Sep 06 '13 at 11:16
  • No, see [my link above](http://www.php.net/manual/en/xml.requirements.php): it is about XMLReader (!) and shows that XMLReader **is Expat**... Both (SAX and Expat) are event-driven parsers, but I prefer the SAX interface than Expat, and the LibXML2 (apparently faster!) reuse than use of another lib. – Peter Krauss Sep 06 '13 at 11:24
  • No you misread that. XML Parser is Expat (by default). XMLReader is just libxml so I thought it might use SAX of it internally. In any case, if you need the SAX methods directly, you need to create your own binding to them. AFAIK no binding so far exists, but I have not researched specifically as this was not necessary for me so far. -- Related Q&A: [Is XMLReader a SAX parser, a DOM parser, or neither?](http://stackoverflow.com/q/3048437/367456) – hakre Sep 06 '13 at 11:32
  • Thanks (!). I edited, adding your link and "Terminology", to avoid more confusions. – Peter Krauss Sep 06 '13 at 12:21

0 Answers0