XML DOM Document objekt

The Document object represents the entire XML document.

XML document object

The Document object is the root of an XML document tree, providing us with the main entry point to access document data.

Since element nodes, text nodes, comments, processing instructions, etc., cannot exist outside the document, the Document object also includes methods for creating these objects. The Node object has an ownerDocument property that associates them with the Document that created them.

Properties of the Document object

Egenskap Beskrivning
childNodes Return the NodeList of child nodes of the document.
doctype Return the document type declaration associated with the document.
documentElement Return the root node of the document.
documentURI Set or return the position of the document.
domConfig Return the configuration used when calling normalizeDocument().
firstChild Return the first child node of the document.
implementation Return the DOMImplementation object that handles this document.
inputEncoding Return the encoding method used by the document (at parsing time).
lastChild Returnera det sista barnnoden för dokumentet.
nodeName Returnera namnet på noden (beroende på dess typ).
nodeType Returnera nodens nodtyp.
nodeValue Sätt eller returnera nodens värde (beroende på dess typ).
xmlEncoding Returnera XML-kodningen för dokumentet.
xmlStandalone Sätt eller returnera om dokumentet är självständigt.
xmlVersion Sätt eller returnera XML-versionen för dokumentet.

Metoder för Document-objektet

Metod Beskrivning
adoptNode() Anta en nod från ett annat dokument till detta dokument och returnera den antagna noden.
createAttribute() Skapa ett attributnod med angivet namn, och returnera det nya Attr-objektet.
createAttributeNS() Skapa ett attributnod med angivet namn och namnrymd, och returnera det nya Attr-objektet.
createCDATASection() Skapa en CDATA section nod.
createComment() Skapa en kommentar nod.
createDocumentFragment() Skapa en tom DocumentFragment-objekt och returnera den.
createElement() Skapa ett elementnod.
createElementNS() Skapa ett elementnod med angiven namnrymd.
createEntityReference() Skapa ett EntityReference-objekt och returnera detta objekt.
createProcessingInstruction() Skapa ett ProcessingInstruction-objekt och returnera detta objekt.
createTextNode() Skapa en textnod.
getElementById() Returnera element med id-egenskap som har det givna värdet.
getElementsByTagName() Returnera NodeList med alla element som har angivet namn.
getElementsByTagNameNS() Returnera NodeList med alla element som har angivet namn och namnrymd.
importNode() Importera en nod från ett annat dokument till detta dokument.
normalizeDocument()
renameNode() Byt namn på elementnod eller egenskapsnod.

Egenskaper för DocumentType-objektet

Varje dokument har en DOCTYPE-attribut, som har värdet null eller ett DocumentType-objekt.

DocumentType-objektet tillhandahåller gränssnitt för definitionen av entiteter för XML-dokument.

Egenskap Beskrivning
name Returnerar namnet på DTD:n.
publicId Returnerar den allmänna identifieraren för DTD:n.
systemId Returnerar systemidentifieraren för den externa DTD:n.

Metoder för DocumentImplementation-objektet

DOMImplementation-objektet utför operationer som är oberoende av dokumentobjektmodellen för en specifik instans.

Metod Beskrivning
createDocument() Skapa ett nytt DOM Document-objekt av det specificerade dokumenttypen.
createDocumentType() Skapa en tom DocumentType-nod.
getFeature() Returnerar ett objekt för API som implementerar den specificerade egenskapen och versionen (om det finns).
hasFeature() Kontrollera om DOM-implementeringen har implementerat specifika egenskaper och versioner.

Egenskaperna hos ProcessingInstruction-objektet

ProcessingInstruction-objektet representerar en behandlingsinstruktion.

Behandlingsinstruktion används som en metod för att behålla processor-specifik information i XML-dokumenttexten.

Egenskap Beskrivning
data Ställ in eller returnera innehållet för denna behandlingsinstruktion.
target Återvänd till målet för denna behandlingsinstruktion.