Interface Document
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.
Template arguments
interface Document(DOMString);
Properties
Name | Type | Description |
---|---|---|
doctype
[get]
|
DocumentType!DOMString |
The DocumentType associated with this document. For XML documents without a
document type declaration this returns null .
|
documentElement
[get]
|
DOMImplementation |
This is a convenience attribute that allows direct access to the child node that is the document element of the document. |
documentURI
[get, set]
|
DOMString |
The location of the document or null if undefined or if the Document
was created using DOMImplementation . No lexical checking
is performed when setting this attribute; this could result in a null
value returned when using Node .
|
domConfig
[get]
|
DOMConfiguration!DOMString |
The configuration used when Document is invoked.
|
implementation
[get]
|
DOMImplementation!DOMString |
The DOMImplementation object that handles this document. A DOM application
may use objects from multiple implementations.
|
inputEncoding
[get]
|
DOMString |
An attribute specifying the encoding used for this document at the time of
the parsing. This is null when it is not known, such as when the Document
was created in memory.
|
strictErrorChecking
[get, set]
|
bool |
An attribute specifying whether error checking is enforced or not.
When set to false , the implementation is free to not test every possible
error case normally defined on DOM operations, and not raise any DOMException
on DOM operations or report errors while using Document .
In case of error, the behavior is undefined. This attribute is true by default.
|
xmlEncoding
[get]
|
DOMString |
An attribute specifying, as part of the XML declaration, the encoding of
this document. This is null when unspecified or when it is not known,
such as when the Document was created in memory.
|
xmlStandalone
[get, set]
|
bool |
An attribute specifying, as part of the XML declaration, whether this document
is standalone. This is false when unspecified.
|
xmlVersion
[get, set]
|
DOMString |
An attribute specifying, as part of the XML declaration, the version number
of this document. If there is no declaration and if this document supports
the "XML" feature, the value is "1.0". If this document does not support
the "XML" feature, the value is always null .
|
Methods
Name | Description |
---|---|
createAttribute
|
Creates an Attr of the given name. Note that the Attr instance can
then be set on an Element using the setAttributeNode method.
To create an attribute with a qualified name and namespace URI, use the
createAttributeNS method.
|
createAttributeNS
|
Creates an attribute of the given qualified name and namespace URI.
Per the XML Namespaces specification, applications must use the value null
as the namespaceURI parameter for methods if they wish to have no namespace.
|
createCDATASection
|
Creates a CDATASection node whose value is the specified string.
|
createComment
|
Creates a Comment node given the specified string.
|
createDocumentFragment
|
Creates an empty DocumentFragment object.
|
createElement
|
Creates an Element of the type specified.
In addition, if there are known attributes with default values, Attr nodes
representing them are automatically created and attached to the element.
To create an Element with a qualified name and namespace URI, use the
createElementNS method.
|
createElementNS
|
Creates an Element of the given qualified name and namespace URI.
Per the XML Namespaces specification, applications must use the value null
as the namespaceURI parameter for methods if they wish to have no namespace.
|
createEntityReference
|
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.
|
createProcessingInstruction
|
Creates a ProcessingInstruction node given the specified name and data strings.
|
createTextNode
|
Creates a Text node given the specified string.
|
getElementById
|
Returns the Element that has an ID attribute with the given value. If no
such element exists, this returns null . If more than one element has an
ID attribute with that value, what is returned is undefined.
The DOM implementation is expected to use the attribute Attr to
determine if an attribute is of type ID.
|
getElementsByTagName
|
Returns a NodeList of all the Element s in document order with a given
tag name and are contained in the document.
|
getElementsByTagNameNS
|
Returns a NodeList of all the Element s with a given local name and
namespace URI in document order.
|
importNode
|
Imports a node from another document to this document, without altering or
removing the source node from the original document; this method creates a
new copy of the source node. The returned node has no parent; (parentNode is null ).
|
normalizeDocument
|
This method acts as if the document was going through a save and load cycle,
putting the document in a "normal" form. As a consequence, this method
updates the replacement tree of EntityReference nodes and normalizes Text
nodes, as defined in the method Node.normalize().
|
renameNode
|
Rename an existing node of type ELEMENT or ATTRIBUTE .
|
Authors
Lodovico Giaretta
Copyright
Copyright Lodovico Giaretta 2016 --