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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.