O'Reilly logo

Special Edition Using Java™ 2 Enterprise Edition by Mark Wutka

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing an XML Document with Java

As you can see, generating an XML document is fairly trivial. Reading an XML document is a little trickier, and that's where a parser comes in. There are two main flavors of XML parsers: SAX and DOM. SAX stands for Simple API for XML and is an event-based parser. When a SAX parser reads through an XML file, it sends an event to a handler class that you write. SAX parsers tend to be fast, but they can be cumbersome to use for complex documents.

Document Object Model (DOM) parsers read the whole document and create a Java representation of the object. The advantage of DOM is that it is usually easier to navigate through the document because you have everything you need. When you use SAX, you must keep track of ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required