O'Reilly logo

Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition by Ivor Horton

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

23.2. Summary

In this chapter I've discussed how you can use a DOM parser to analyze XML and how JAXP supports the synthesis and modification of XML documents using DOM. The key points I have covered include the following:

  • An object of type DocumentBuilder encapsulates a DOM parser.

  • You create an object encapsulating a DOM parser by using a DocumentBuilderFactory object that you obtain by calling the static newInstance() method that is defined in the DocumentFactoryBuilder class.

  • You can parse an XML document by passing the document as an argument to the parse() method for a DocumentBuilder object.

  • A DOM parser creates a Document object that encapsulates an entire XML document as a tree of Node objects.

  • The DOM API defines the methods of a Document object that enable you to analyze an XML document by navigating through the nodes in the Document object.

  • The DOM API also defines methods for creating a new XML document encapsulated by a Document object.

  • When you want to create a new XML document that includes a DTD, you should use the createDocument() method for a DOMImplementation object, rather than the newDocument() method for a DocumentBuilder object.

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