PHP not have access to the LibXML2 SAX interface?
Asked Answered
C

0

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

Caliphate answered 6/9, 2013 at 11:13 Comment(4)
You are most likely looking for XMLReader. php.net/XMLReaderCarboxylase
No, see my link above: 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.Caliphate
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?Carboxylase
Thanks (!). I edited, adding your link and "Terminology", to avoid more confusions.Caliphate

© 2022 - 2024 — McMap. All rights reserved.