Intro to XML: Parsers & Tools (manipulation)

Parsers

In the Browser

Different browsers handle the parsing of XML data differently. You can however write JavaScript code which handles the cross-platform issues for you.

From the Commandline

While we often want to work with XML in a browser context, we can also do so either from the commandline or from within an application.

SAX versus DOM

What are the Basic Differences?

SAX is the "Simple Api for Xml processing". SAX is event-driven. DOM is the "Document Object Model". DOM is result-tree-driven. SAX is simple, but requires you to build the tree (or other data structure) yourself. DOM is complex, but builds a result-tree for you.

Examples

I have posted some Java examples of using SAX, along with an example XML data file. Note that the examples I have posted are pretty generic, in that the crude pretty printer (SAXPrinter.java) and the simple word counter (SAXWordCount) will take any XML data file as input.

Questions to Ask Yourself

How could you improve SAXPrinter? What about SAXWordCount? Are these programs validating the input data? Why/why-not? How could you do the same thing with DOM? Which seems more efficient? Why?


revalidate the HTML revalidate the CSS Pastafarian Flag

Last modified: 2 Sep 2007 12:28:10 PM