Resources | Resources |



XML parser

The XML parser is an XML (Extensible Markup Language) parser/builder that allows you to build or parse an XML document. XML is a set of rules for encoding documents in machine-readable form and can represent arbitrary data structures. XML documents are encoded either in text (XML) or binary WAP Binary XML (WBXML). The XML parser is a SAX-based parser.

Brew MP provides the following interfaces for the XML Parser:

  • ISAXParser: A way to read an XML document
  • ISAXBuilder: A way to construct or build an XML document
  • IWBXMLTables: A compressed way to represent XML data in both XML ASCII and binary

SAX parser

SAX, or Simple interface for XML, is a serial access parser interface for XML that provides a mechanism for reading data from an XML document. SAX functions as a stream parser with an event-driven API. The user defines a number of callback methods that are called when events occur during parsing. The SAX events include:

  • XML text nodes
  • XML element nodes
  • XML processing instructions
  • XML comments

Events are fired when each of these XML features are encountered, and again when the end of them is encountered. XML attributes are provided as part of the data passed to element events.

SAX parsing is unidirectional; previously parsed data cannot be reread without starting the parsing operation again.

SAX parsers have certain benefits over DOM-style parsers, one of which is memory consumption. A SAX parser uses a smaller quantity of memory than a DOM parser, because its memory footprint is based only on the maximum depth of the XML file (the maximum depth of the XML tree) and the maximum data stored in XML attributes on a single XML element; whereas the DOM parser must have the entire parsed tree in memory before any processing can begin. Because of the event-driven nature of SAX, processing documents can be faster than DOM-style parsers.

One of the drawbacks of a SAX parser is that certain kinds of XML validation and processing require access to the document in full.

WBXML tables

WBXML is a binary representation of XML. It allows XML documents to be transmitted in a compact manner over mobile networks. These tables define translation of XML element types to codes. By providing appropriate tables, any XML document can be translated into its binary equivalent.