Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
XML
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Pull parsing === Pull parsing treats the document as a series of items read in sequence using the [[Iterator pattern|iterator design pattern]]. This allows for writing of [[recursive descent parser]]s in which the structure of the code performing the parsing mirrors the structure of the XML being parsed, and intermediate parsed results can be used and accessed as local variables within the functions performing the parsing, or passed down (as function parameters) into lower-level functions, or returned (as function return values) to higher-level functions.<ref>{{cite web|url=http://www.xml.com/pub/a/2005/07/06/tr.html|title=Push, Pull, Next!|first=Bob|last=DuCharme|website=Xml.com|access-date=16 November 2017}}</ref> Examples of pull parsers include Data::Edit::Xml in [[Perl]], [[StAX]] in the [[Java (programming language)|Java]] programming language, XMLPullParser in [[Smalltalk]], XMLReader in [[PHP]], ElementTree.iterparse in [[Python (programming language)|Python]], SmartXML in [[Red (programming language)|Red]], System.Xml.XmlReader in the [[.NET Framework]], and the DOM traversal API (NodeIterator and TreeWalker). A pull parser creates an iterator that sequentially visits the various elements, attributes, and data in an XML document. Code that uses this iterator can test the current item (to tell, for example, whether it is a start-tag or end-tag, or text), and inspect its attributes (local name, [[XML namespace|namespace]], values of XML attributes, value of text, etc.), and can also move the iterator to the next item. The code can thus extract information from the document as it traverses it. The recursive-descent approach tends to lend itself to keeping data as typed local variables in the code doing the parsing, while SAX, for instance, typically requires a parser to manually maintain intermediate data within a stack of elements that are parent elements of the element being parsed. Pull-parsing code can be more straightforward to understand and maintain than SAX parsing code.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)