Simple API for XML
SAX (Simple API for XML) is an event-driven online algorithm for lexing and parsing XML documents, with an API developed by the XML-DEV mailing list. SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the Document Object Model (DOM). Where the DOM operates on the document as a whole—building the full abstract syntax tree of an XML document for convenience of the user—SAX parsers operate on each piece of the XML document sequentially, issuing parsing events while making a single pass through the input stream.
SAX (Simple API for XML) is an event-driven online algorithm for lexing and parsing XML documents, with an API developed by the XML-DEV mailing list. SAX provides a mechanism for reading data from an XML document that is an alternative to that provided by the Document Object Model (DOM). Where the DOM operates on the document as a whole—building the full abstract syntax tree of an XML document for convenience of the user—SAX parsers operate on each piece of the XML document sequentially, issuing parsing events while making a single pass through the input stream. ¶ Some Text Pre-Text Inlined text Post-text. This XML document, when passed through a SAX parser, will generate a sequence of events like the following: XML Element start, named DocumentElement, with an attribute param equal to "value" XML Element start, named FirstElement XML Text node, with data equal to "¶ Some Text" (note: certain white spaces can be changed) XML Element end, named FirstElement Processing Instruction event, with the target some_pi and data some_attr="some_value" (the content after the target is just text; however, it is very common to imitate the syntax of XML attributes, as in this example) XML Element start, named SecondElement, with an attribute param2 equal to "something" XML Text node, with data equal to "Pre-Text" XML Element start, named Inline XML Text node, with data equal to "Inlined text" XML Element end, named Inline XML Text node, with data equal to "Post-text." XML Element end, named SecondElement XML Element end, named DocumentElement Note that the first line of the sample above is the XML Declaration and not a processing instruction; as such it will not be reported as a processing instruction event (although some SAX implementations provide a separate event just for the XML declaration). The result above may vary: the SAX specification deliberately states that a given section of text may be reported as multiple sequential text events. Many parsers, for example, return separate text events for numeric character references. Thus in the example above, a SAX parser may generate a different series of events, part of which might include: XML Element start, named FirstElement XML Text node, with data equal to "¶" (the Unicode character U+00b6) XML Text node, with data equal to " Some Text" XML Element end, named FirstElement ==References== == Further reading== ==External links== SAX home page
References
- ^ "saxproject.org" . Wikipedia revision 1374334137, retrieved 2026-11-21 · 1795215600.0
- ^ "Simple API for XML" . oracle.com . ORACLE . Retrieved 2011-05-02 . Note: In a nutshell, SAX is oriented towards state independent processing, where the handling of an element does not depend on the elements that came before. StAX, on the other hand, is oriented towards state dependent processing. For a more detailed comparison, see SAX and StAX in Basic Standards and When to Use SAX. Wikipedia revision 1374334137, retrieved 2026-11-21 · 1304290800.0
- ^ Wu, D.; Chau, K. T.; Wang, J.; Pan, C. (January 2019). A comparative study on performance of XML parser APIs (DOM and SAX) in parsing efficiency . 3rd International Conference on Cryptography, Security and Privacy. Kuala Lumpur, Malaysia: Association for Computing Machinery. pp. 88– 92. doi : 10.1145/3309074.3309124 . Wikipedia revision 1374334137, retrieved 2026-11-21 · 1795215600.0
- ^ Wang, Chao (2020). XML Parsing Technique . Innovative Computing: IC 2020. Kuala Lumpur, Malaysia: Springer. pp. 1519– 1526. doi : 10.1007/978-981-15-5959-4_185 . Wikipedia revision 1374334137, retrieved 2026-11-21 · 1795215600.0
- ^ Charlie, Frank (February 2001). "XML Parsers: DOM and SAX Put to the Test" . devX . Retrieved 2011-10-20 . Although these tests do not show it, SAX parsers typically are faster for very large documents where the DOM model hits virtual memory or consumes all available memory. Wikipedia revision 1374334137, retrieved 2026-11-21 · 1319065200.0
- ^ a b "SAX" . webopedia.com . WEBOPEDIA. 14 August 2003 . Retrieved 2011-05-02 . Short for Simple API for XML, an event-based API that, as an alternative to DOM, allows someone to access the contents of an XML document. SAX was originally a Java-only API. The current version supports several programming language environments other than Java. SAX was developed by the members of the XML-DEV mailing list. Wikipedia revision 1374334137, retrieved 2026-11-21 · 1304290800.0
- SAX . webopedia.com . 14 August 2003. retrieved 2011-05-02 · 1304290800.0
- saxproject.org . · 1789081200.0
- Simple API for XML . oracle.com . retrieved 2011-05-02 · 1304290800.0
- Charlie, Frank. XML Parsers: DOM and SAX Put to the Test . devX . Februa. retrieved 2011-10-20 · 1319065200.0
Cite this
"Simple API for XML". 1789116520. e01 Encyclopedia. CC BY-SA 4.0. https://en.wikipedia.org/w/index.php?oldid=1374334137 JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy