Document 对象代表整个 XML 文档。
Document 对象是 XML 文档树的根,它为我们提供了对文档数据的主要访问权限。
由于元素节点、文本节点、注释、处理指令等不能存在于文档之外,因此Document对象还包含创建这些对象的方法。 Node 对象有一个ownerDocument 属性,该属性将它们与创建它们的Document 关联起来。
Property | Description |
---|---|
childNodes | Returns a NodeList of child nodes for the document |
doctype | Returns the Document Type Declaration associated with the document |
documentElement | Returns the root node of the document |
documentURI | Sets or returns the location of the document |
domConfig | Returns the configuration used when normalizeDocument() is invoked |
firstChild | Returns the first child node of the document |
implementation | Returns the DOMImplementation object that handles this document |
inputEncoding | Returns the encoding used for the document (when parsing) |
lastChild | Returns the last child node of the document |
nodeName | Returns the name of a node (depending on its type) |
nodeType | Returns the node type of a node |
nodeValue | Sets or returns the value of a node (depending on its type) |
xmlEncoding | Returns the XML encoding of the document |
xmlStandalone | Sets or returns whether the document is standalone |
xmlVersion | Sets or returns the XML version of the document |
Method | Description |
---|---|
adoptNode(sourcenode) | Adopts a node from another document to this document, and returns the adopted node |
createAttribute(name) | Creates an attribute node with the specified name, and returns the new Attr object |
createAttributeNS(uri,name) | Creates an attribute node with the specified name and namespace, and returns the new Attr object |
createCDATASection() | Creates a CDATA section node |
createComment() | Creates a comment node |
createDocumentFragment() | Creates an empty DocumentFragment object, and returns it |
createElement() | Creates an element node |
createElementNS() | Creates an element node with a specified namespace |
createEntityReference(name) | Creates an EntityReference object, and returns it |
createProcessingInstruction(target,data) | Creates a ProcessingInstruction object, and returns it |
createTextNode() | Creates a text node |
getElementById(id) | Returns the element that has an ID attribute with the given value. If no such element exists, it returns null |
getElementsByTagName() | Returns a NodeList of all elements with a specified name |
getElementsByTagNameNS() | Returns a NodeList of all elements with a specified name and namespace |
importNode(nodetoimport,deep) | Imports a node from another document to this document. This method creates a new copy of the source node. If the deep parameter is set to true, it imports all children of the specified node. If set to false, it imports only the node itself. This method returns the imported node |
normalizeDocument() | |
renameNode() | Renames an element or attribute node |
每个文档都有一个 DOCTYPE 属性,其值为 null 或 DocumentType 对象。
DocumentType 对象提供了为 XML 文档定义的实体的接口。
Property | Description |
---|---|
name | Returns the name of the DTD |
publicId | Returns the public identifier of the DTD |
systemId | Returns the system identifier of the external DTD |
DOMImplementation 对象执行独立于文档对象模型的任何特定实例的操作。
Method | Description |
---|---|
createDocument(nsURI, name, doctype) | Creates a new DOM Document object of the specified doctype |
createDocumentType(name, pubId, systemId) | Creates an empty DocumentType node |
getFeature(feature, version) | Returns an object which implements the APIs of the specified feature and version, if the is any |
hasFeature(feature, version) | Checks whether the DOM implementation implements a specific feature and version |
ProcessingInstruction 对象表示一条处理指令。
处理指令用作将处理器特定信息保留在 XML 文档文本中的方法。
Property | Description |
---|---|
data | Sets or returns the content of this processing instruction |
target | Returns the target of this processing instruction |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!