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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.