The Document Object Model (DOM) APIs
The DOM Packages
The Document Object Model implementation is defined in the following packages:
Package | Description |
org.w3c.dom | This package defines the DOM programming interfaces for XML documents, as per with the specifications defined by the W3C. |
javax.xml.parsers | This package defines the DocumentBuilderFactory class and the DocumentBuilder class. The DocumentBuilder class, returns an object needed to implement the W3C Document interface. The factory that creates the builder is determined by the javax.xml.parsers system property. This package also defines the ParserConfigurationException class to deal with errors. |
The diagram here shows the JAXP APIs to process xml document using the DOM parser:
javax.xml.parsers.DocumentBuilderFactory class creates the instance of DocumentBuilder. Through DocumentBuilder it produces a Document (a DOM) that conforms to the DOM specification. The System property determines , the builder at the run time using javax.xml.parsers.DocumentBuilderFactory (it selects the factory implementations to produce the builder). The platform's default value ie..system property can be overridden from the command line.
DocumentBuilder newDocument()
method can also be used . It creates an empty Document that implements the
org.w3c.dom.Document interface.
Alternatively, one of the builder's parse methods can be used to create a Document from existing XML data. As a result, a DOM tree like that shown in the diagram.