All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface org.w3c.dom.Document

public interface Document
extends Node
The Document interface represents the entire HTML or XML document. Conceptually, it is the root of the document tree, and provides the primary access to the document's data.

Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a Document, the Document interface also contains the factory methods needed to create these objects. The Node objects created have a ownerDocument attribute which associates them with the Document within whose context they were created.


Method Index

 o createAttribute(String)
Creates an Attr of the given name.
 o createCDATASection(String)
Creates a CDATASection node whose value is the specified string.
 o createComment(String)
Creates a Comment node given the specified string.
 o createDocumentFragment()
Creates an empty DocumentFragment object.
 o createElement(String)
Creates an element of the type specified.
 o createEntityReference(String)
Creates an EntityReference object.
 o createProcessingInstruction(String, String)
Creates a ProcessingInstruction node given the specified name and data strings.
 o createTextNode(String)
Creates a Text node given the specified string.
 o getDoctype()
The Document Type Declaration (see DocumentType) associated with this document.
 o getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document.
 o getElementsByTagName(String)
Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.
 o getImplementation()
The DOMImplementation object that handles this document.

Methods

 o getDoctype
 public abstract DocumentType getDoctype()
The Document Type Declaration (see DocumentType) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns null. The DOM Level 1 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way.

 o getImplementation
 public abstract DOMImplementation getImplementation()
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.

 o getDocumentElement
 public abstract Element getDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".

 o createElement
 public abstract Element createElement(String tagName) throws DOMException
Creates an element of the type specified. Note that the instance returned implements the Element interface, so attributes can be specified directly on the returned object.

Parameters:
tagName - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the tagName parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.
Returns:
A new Element object.
Throws: DOMException
INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
 o createDocumentFragment
 public abstract DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment object.

Returns:
A new DocumentFragment.
 o createTextNode
 public abstract Text createTextNode(String data)
Creates a Text node given the specified string.

Parameters:
data - The data for the node.
Returns:
The new Text object.
 o createComment
 public abstract Comment createComment(String data)
Creates a Comment node given the specified string.

Parameters:
data - The data for the node.
Returns:
The new Comment object.
 o createCDATASection
 public abstract CDATASection createCDATASection(String data) throws DOMException
Creates a CDATASection node whose value is the specified string.

Parameters:
data - The data for the CDATASection contents.
Returns:
The new CDATASection object.
Throws: DOMException
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
 o createProcessingInstruction
 public abstract ProcessingInstruction createProcessingInstruction(String target,
                                                                   String data) throws DOMException
Creates a ProcessingInstruction node given the specified name and data strings.

Parameters:
target - The target part of the processing instruction.
data - The data for the node.
Returns:
The new ProcessingInstruction object.
Throws: DOMException
INVALID_CHARACTER_ERR: Raised if an invalid character is specified.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
 o createAttribute
 public abstract Attr createAttribute(String name) throws DOMException
Creates an Attr of the given name. Note that the Attr instance can then be set on an Element using the setAttribute method.

Parameters:
name - The name of the attribute.
Returns:
A new Attr object.
Throws: DOMException
INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
 o createEntityReference
 public abstract EntityReference createEntityReference(String name) throws DOMException
Creates an EntityReference object.

Parameters:
name - The name of the entity to reference.
Returns:
The new EntityReference object.
Throws: DOMException
INVALID_CHARACTER_ERR: Raised if the specified name contains an invalid character.
NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
 o getElementsByTagName
 public abstract NodeList getElementsByTagName(String tagname)
Returns a NodeList of all the Elements with a given tag name in the order in which they would be encountered in a preorder traversal of the Document tree.

Parameters:
tagname - The name of the tag to match on. The special value "*" matches all tags.
Returns:
A new NodeList object containing all the matched Elements.

All Packages  Class Hierarchy  This Package  Previous  Next  Index