Parsing Documents with a DOM Parser

Unlike SAX, DOM does not have a class or interface that represents the XML parser. Each parser vendor provides its own unique class.

  • In Xerces, it's org.apache.xerces.parsers.DOMParser.

  • In Crimson, it's org.apache.crimson.jaxp.DocumentBuilderImpl.

  • In Ælfred, it's an inner class, gnu.xml.dom.JAXPFactory$JAXPBuilder.

  • In Oracle, it's oracle.xml.parser.v2.DOMParser.

  • In other implementations, it will be something else.

Furthermore, because these classes do not share a common interface or superclass, the methods they use to parse documents vary too. For example, in Xerces the two methods that read XML documents have these signatures:

public void parse (InputSource source) throws SAXException, IOException public void ...

Get Processing XML with Java™: A Guide to SAX, DOM, JDOM, JAXP, and TrAX now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.