Re: PACKAGE PROPOSAL: XML_XMLPull

From: Date: Sat, 13 Sep 2003 01:57:13 +0000
Subject: Re: PACKAGE PROPOSAL: XML_XMLPull
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21458@lists.php.net to get a copy of this message
Again +1 on the idea.. - The implementation needs a bit more thought... - It's increadibly heavy.. - to understand it a newcommer has to look at 8 files. while it shows textbook OOP practice, it ignores the fact that the solution is more complex than the problem. XML_PullParser // Interface, (for Listener and Push Listener) // & factory class, // base code for listener.. // see DB/etc. for how to implement factories that load // instantate Expat and HTMLSax (rather than switch/case) ** basically by looking at this single file you should be able understand what the whole package does... + XML_PullParser_Expat extends XML_PullParser + XML_PullParser_HTMLSax extends XML_PullParser XMLEvent* .... StartElement/EndElement : - I'd use an array - it's only a very simple cache of whats been parsed.. - and about to be returned. While I love objects ... there are limits when the structures are simple enough to fall back on arrays.. Regards Alan Harry Fuecks wrote:
Would like to propose PEAR::XML_XMLPull, which is a pull based API for parsing XML, that (arguably) makes it alot easier to parse XML. I've prepared a PEAR package (0.1.0rc1) here: http://sourceforge.net/project/showfiles.php?group_id=87488&release_id=184205 - you need to have PEAR::XML_SaxFilters 0.2.0 installed first to run the example. Essentially what XMLPull does is eliminate the need for handler functions (as with the SAX API) and rather deal with something like a switch statement, e.g.; while ( $event = $parser->parse() ) { switch ( $type = $event->getType() ) {
       case XML_PULL_START_TAG:
        // Start tag handled here
       break;
       case XML_PULL_END_TAG:
        // End tag handled here
       break;
       case XML_PULL_TEXT:
        // Character data handled here
       break;
} } There's more info on XML Pull at http://www.xmlpull.org (the API I've defined only loosely conforms to the Java API described there).
-- Can you help out? Need Consulting Services or Know of a Job? http://www.akbkhome.com

« previous php.pear.dev (#21458) next »