The Document Interface as a Node Type

In addition to the factory methods and the methods common to all nodes, the Document interface has unique methods that perform operations relevant only to document nodes. These include

  • Getter methods

  • Methods to find elements

  • A method to copy nodes from other documents

Getter Methods

The Document interface has three methods that simply return particular parts of the document:

public Element getDocumentElement() 
public DocumentType getDoctype()
public DOMImplementation getImplementation()

These are fairly self-explanatory. You've already seen the getDocumentElement() method used several times. It returns the Element object that represents the root element of the document. Similarly, the getDoctype() method ...

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.