An introduction to three XML APIs

DOM:

  • DOM stands for Document Object Model.
  • Memory intensive. The entire document is read into memory.
  • Read-write
  • Typically used for working with documents smaller than 10 megabytes

SAX:

  • SAX is the Simple API for XML.
  • Memory efficient
  • Read-only
  • Typically used for working with documents largerer than 10 megabytes
  • The programmer writes code that handles events that are fired when the XML parser reads the elements of the XML document. This is known as a push technology.

StAX:

  • StAX is the Streaming API for XML.
  • Memory efficient.
  • Read-write
  • Appropriate for documents of all sizes
  • Easier to use than DOM and SAX
  • The programmer writes code that controls when and how the XML parser reads and writes the XML document. This is known as a pull technology.

Description:

  • StAX is the newest version of the three.

Note:

  • I will only cover the newer StAX going forward..