|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.
Property Summary | ||
doctype |
getDoctype | The Document Type Declaration (see |
implementation |
getImplementation | The |
documentElement |
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". |
Fields inherited from interface org.w3c.dom.Node |
ATTRIBUTE_NODE,
CDATA_SECTION_NODE,
COMMENT_NODE,
DOCUMENT_FRAGMENT_NODE,
DOCUMENT_NODE,
DOCUMENT_TYPE_NODE,
ELEMENT_NODE,
ENTITY_NODE,
ENTITY_REFERENCE_NODE,
NOTATION_NODE,
PROCESSING_INSTRUCTION_NODE,
TEXT_NODE |
Method Summary | |
Attr |
createAttribute(java.lang.String name)
Creates an Attr of the given name. |
CDATASection |
createCDATASection(java.lang.String data)
Creates a CDATASection node whose value is
the specified string. |
Comment |
createComment(java.lang.String data)
Creates a Comment node given the specified
string. |
DocumentFragment |
createDocumentFragment()
Creates an empty DocumentFragment object. |
Element |
createElement(java.lang.String tagName)
Creates an element of the type specified. |
EntityReference |
createEntityReference(java.lang.String name)
Creates an EntityReference object. |
ProcessingInstruction |
createProcessingInstruction(java.lang.String target,
java.lang.String data)
Creates a ProcessingInstruction node given
the specified name and data strings. |
Text |
createTextNode(java.lang.String data)
Creates a Text node given the specified
string. |
DocumentType |
getDoctype()
Returns the value of the doctype property. |
Element |
getDocumentElement()
Returns the value of the documentElement property. |
NodeList |
getElementsByTagName(java.lang.String tagname)
Returns a NodeList of all the Element s
with a given tag name in the order in which they would be encountered
in a preorder traversal of the Document tree. |
DOMImplementation |
getImplementation()
Returns the value of the implementation property. |
Methods inherited from interface org.w3c.dom.Node |
appendChild,
cloneNode,
getAttributes,
getChildNodes,
getFirstChild,
getLastChild,
getNextSibling,
getNodeName,
getNodeType,
getNodeValue,
getOwnerDocument,
getParentNode,
getPreviousSibling,
hasChildNodes,
insertBefore,
removeChild,
replaceChild,
setNodeValue |
Method Detail |
public DocumentType getDoctype()
doctype
property.public DOMImplementation getImplementation()
implementation
property.public Element getDocumentElement()
documentElement
property.public Element createElement(java.lang.String tagName) throws DOMException
Creates an element of the type specified. Note that the
instance returned implements the
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.Element
object.public DocumentFragment createDocumentFragment()
Creates an empty DocumentFragment
object.
DocumentFragment
.public Text createTextNode(java.lang.String data)
Creates a Text
node given the specified
string.
data
- The data for the node.Text
object.public Comment createComment(java.lang.String data)
Creates a Comment
node given the specified
string.
data
- The data for the node.Comment
object.public CDATASection createCDATASection(java.lang.String data) throws DOMException
Creates a CDATASection
node whose value is
the specified string.
data
- The data for the CDATASection
contents.CDATASection
object.public ProcessingInstruction createProcessingInstruction(java.lang.String target, java.lang.String data) throws DOMException
Creates a ProcessingInstruction
node given
the specified name and data strings.
target
- The target part of the processing instruction.data
- The data for the node.ProcessingInstruction
object.NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
public Attr createAttribute(java.lang.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.
name
- The name of the attribute.Attr
object.public EntityReference createEntityReference(java.lang.String name) throws DOMException
Creates an EntityReference object.
name
- The name of the entity to reference.EntityReference
object.NOT_SUPPORTED_ERR: Raised if this document is an HTML document.
public NodeList getElementsByTagName(java.lang.String tagname)
Returns a NodeList
of all the Element
s
with a given tag name in the order in which they would be encountered
in a preorder traversal of the Document
tree.
tagname
- The name of the tag to match on. The special value "*"
matches all tags.NodeList
object containing
all the matched Element
s.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |