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 XML with SAX and DOM

When a client sends XML to your server, you must be able to parse the XML document. Obviously, you need either a servlet or a Java Server Page to parse the data. Most of the time, you want to parse the data from a servlet and possibly forward to a JSP to generate any XML output. You can use any of several different parsers to turn XML documents into Java data structures.

There are two different approaches for parsing XML in Java: SAX (Simple API for XML) and DOM (Document Object Model). SAX allows you to handle XML tags in the data as the parser encounters them. In other words, when the parser locates an XML tag, it calls a Java method to handle the tag. It's up to you to decide what to do with it. DOM isn't strictly ...

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