Object na Document sa XML DOM

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

Atribute Paglalarawan
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 processes this document.
inputEncoding Return the encoding method used by the document (at parsing time).
lastChild I-bakas ang huling anak na node ng dokumento.
nodeName I-bakas ang pangalan ng node ( depende sa uri ng node).
nodeType I-bakas ang uri ng uri ng node.
nodeValue I-set o ibabalik ang halaga ng node ( depende sa uri ng node).
xmlEncoding I-bakas ang XML na encoding ng dokumento.
xmlStandalone I-set o ibabalik kung ang dokumento ay malayang nakakabit o hindi.
xmlVersion I-set o ibabalik ang XML na bersyon ng dokumento.

Method ng Document na object

Metodong Paglalarawan
adoptNode() I-adopta ang node mula sa ibang dokumento sa kasalukuyang dokumento, at ibabalik ang na-adopted na node.
createAttribute() Lumikha ng attribute na node na may tinukoy na pangalan, at ibabalik ang bagong Attr na object.
createAttributeNS() Lumikha ng attribute na node na may tinukoy na pangalan at namespace, at ibabalik ang bagong Attr na object.
createCDATASection() Lumikha ng CDATA section na node.
createComment() Lumikha ng comment na node.
createDocumentFragment() Lumikha ng walang laman na DocumentFragment na object at ibabalik ito.
createElement() Lumikha ng elemento na node.
createElementNS() Lumikha ng elemento na may tinukoy na namespace.
createEntityReference() Lumikha ng EntityReference na object at ibabalik ang object na ito.
createProcessingInstruction() Lumikha ng ProcessingInstruction na object at ibabalik ang object na ito.
createTextNode() Lumikha ng text na node.
getElementById() I-bakas ang elemento na may tinukoy na halaga ng id na attribute.
getElementsByTagName() I-bakas ang NodeList ng lahat ng elemento na may tinukoy na pangalan.
getElementsByTagNameNS() I-bakas ang NodeList ng lahat ng elemento na may tinukoy na pangalan at namespace.
importNode() I-importahin ang node mula sa ibang dokumento sa kasalukuyang dokumento.
normalizeDocument()
renameNode() Muling pangalanin ang elemento o attribute na node.

Attribute ng DocumentType na object

Bawat dokumento ay mayroong isang DOCTYPE na attribute, na may halaga na null o DocumentType na object.

Ang DocumentType object ay nagbibigay ng interface para sa entity na itinukoy ng dokumentong XML.

Atribute Paglalarawan
name Ibalik ang pangalan ng DTD.
publicId Ibalik ang public identifier ng DTD.
systemId Ibalik ang system identifier ng panlabas na DTD.

Mga metodong may iisang DocumentImplementation object

Ang DOMImplementation object ay nagpapatupad ng mga operasyon na hindi kaugnay sa dokumentong object model.

Metodong Paglalarawan
createDocument() Lumikha ng bagong DOM Document object na may tinukoy na dokumentong uri.
createDocumentType() Lumikha ng walang laman na DocumentType node.
getFeature() Ibalik ang object ng API na nagtatanggap ng mga espesyal na katangian at bersyon ng implementasyon (kung mayroon).
hasFeature() Surungin kung ang implementasyon ng DOM ay nagtatanggap ng mga espesyal na katangian at bersyon.

Atribute ng ProcessingInstruction object

Ang ProcessingInstruction object ay ipinapakita ng processing instruction.

Ang processing instruction ay ginagamit bilang paraan upang panatilihin ang malalagay na impormasyon ng processor sa teksto ng dokumentong XML.

Atribute Paglalarawan
data Iset o ibalik ang nilalaman ng processing instruction.
target Bumalik sa layunin ng processing instruction.