XML DOM - Die dokumentvoorwerp
Die Dokument-objek verteenwoordig die hele XML-dokument.
Die XML-dokumentobjek
Die Dokument-objek is die wortel van 'n XML-dokumentboom, en gee ons die primêre toegang tot die dokument se data.
Aangesien elementnodusse, teksnodes, opmerkings, verwerkingsinstruksies, ens. nie buite die dokument kan bestaan nie, bevat die Dokument-objek ook metodes om hierdie objekte te skep. Die Node-objekte het 'n eienaarDocument-eienskap wat hulle assosieer met die Dokument waar hulle geskep is.
Dokumentobjek-eienskappe
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 |
Dokumentobjekmetodes
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 |
DocumentType Object Properties
Elke dokument het 'n DOCTYPE-kenmerk waarvan die waarde óf nul óf 'n DocumentType-objek is.
Die DocumentType-objek bied 'n koppelvlak aan die entiteite wat vir 'n XML-dokument gedefinieer is.
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 |
DokumentImplementasie-objekmetodes
Die DOMImplementation-objek voer bewerkings uit wat onafhanklik is van enige spesifieke geval van die dokument-objekmodel.
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 Object Properties
Die ProcessingInstruction-objek verteenwoordig 'n verwerkingsinstruksie.
'n Verwerkingsinstruksie word gebruik as 'n manier om verwerkerspesifieke inligting in die teks van die XML-dokument te hou.
Property | Description |
---|---|
data | Sets or returns the content of this processing instruction |
target | Returns the target of this processing instruction |