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.
DOMDocument New()
Create a new DOMDocument node, to be used to build a DOM tree in memory.
DOMDocumentType 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 2 does not support editing the Document Type Declaration, therefore docType cannot be altered in any way, including through the use of methods, such as insertNode or removeNode, inherited from Node. Not implemented.
DOMImplementation GetImplementation()
The DOMImplementation object that handles this document. A DOM application may use objects from multiple implementations.
DOMElement GetDocumentElement()
This is a convenience attribute that allows direct access to the child node that is the root element of the document.
DOMElement CreateElement( String tagName )
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. In addition, if there are known attributes with default values, Attr nodes representing them are automatically created and attached to the element.
tagName | - | The name of the element. |
DOMDocumentFragment CreateDocumentFragment()
Creates an empty DocumentFragment object.
DOMText CreateTextNode( String data )
Creates a Text node given the specified string.
data | - | The data for the text node. |
DOMComment CreateComment( String data )
Creates a Comment node given the specified string.
data | - | The data for the comment node. |
DOMCDATASection CreateCDATASection( String data )
Creates a CDATASection node whose value is the specified string.
data | - | The data for the CDATASection node. |
DOMProcessingInstruction CreateProcessingInstruction( String target, String data )
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. |
DOMAttr CreateAttribute( String name )
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. |
DOMEntityReference CreateEntityReference( String name )
Creates an EntityReference object. In addition, if the referenced entity is known, the child list of the EntityReference node is made the same as that of the corresponding Entity node.
name | - | The name of the entity to reference. |
DOMNodeList 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.
tagName | - | The name of the tag to match on. The special value "*" matches all tags. |