JAXP DOM: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 16: Line 16:
The JAXP DOM implementation supports [[XML Schema]], so documents can be validated on parsing.
The JAXP DOM implementation supports [[XML Schema]], so documents can be validated on parsing.


=DOM Example=
=DOM Examples=


<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
<blockquote style="background-color: #f9f9f9; border: solid thin lightgrey;">
:[[JAXP DOM Example|DOM Example]]
:[[JAXP DOM Examples|DOM Examples]]
</blockquote>
</blockquote>



Revision as of 17:36, 10 November 2016

Internal

Overview

The JAXP DOM API is defined by W3C. The parsers implementing the DOM API translates an entire XML document into a memory tree structure, where each node contains on of the components of an XML structure. The Document tree elements are low level data structures. For higher level object structures, use JDOM or dom4j parsers instead.

Unlike an event-driver parser API, the DOM API is memory and CPU intensive.

The parsing process begins by using DocumentBuilderFactory to create a DocumentBuilder instance. The actual implementation is dictated by the value of the javax.xml.parsers.DocumentBuilderFactory system property. The DocumentBuilder produces a Document object as a result of a parse() method invocation. DOM and SAX parsers handle errors in a similar manner, the same exceptions are generated so the error handling code is virtually identical.

The JAXP DOM implementation supports XML Schema, so documents can be validated on parsing.

DOM Examples

DOM Examples

Component Packages

  • javax.xml.parsers defines DocumentBuilderFactory and DocumentBuilder classes, and error types.
  • org.w3c.dom defines the Document class and other DOM components.