एक्सएमएल डोम नोड प्रकार
DOM एक दस्तावेज़ को नोड ऑब्जेक्ट्स के पदानुक्रम के रूप में प्रस्तुत करता है।
इसे स्वयं आज़माएं - उदाहरण
नीचे दिए गए उदाहरण XML फ़ाइल Books.xml का उपयोग करते हैं ।
नोड प्रकार
निम्न तालिका विभिन्न W3C नोड प्रकारों को सूचीबद्ध करती है, और बच्चों के रूप में उनके पास कौन से नोड प्रकार हो सकते हैं:
Node Type | Description | Children |
---|---|---|
Document | Represents the entire document (the root-node of the DOM tree) | Element (max. one), ProcessingInstruction, Comment, DocumentType |
DocumentFragment | Represents a "lightweight" Document object, which can hold a portion of a document | Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
DocumentType | Provides an interface to the entities defined for the document | None |
ProcessingInstruction | Represents a processing instruction | None |
EntityReference | Represents an entity reference | Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Element | Represents an element | Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference |
Attr | Represents an attribute | Text, EntityReference |
Text | Represents textual content in an element or attribute | None |
CDATASection | Represents a CDATA section in a document (text that will NOT be parsed by a parser) | None |
Comment | Represents a comment | None |
Entity | Represents an entity | Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Notation | Represents a notation declared in the DTD | None |
नोड प्रकार - वापसी मान
निम्न तालिका सूचीबद्ध करती है कि प्रत्येक नोड प्रकार के लिए नोडनाम और नोडवैल्यू गुण क्या वापस आएंगे:
Node Type | nodeName returns | nodeValue returns |
---|---|---|
Document | #document | null |
DocumentFragment | #document fragment | null |
DocumentType | doctype name | null |
EntityReference | entity reference name | null |
Element | element name | null |
Attr | attribute name | attribute value |
ProcessingInstruction | target | content of node |
Comment | #comment | comment text |
Text | #text | content of node |
CDATASection | #cdata-section | content of node |
Entity | entity name | null |
Notation | notation name | null |
NodeTypes - नामांकित स्थिरांक
NodeType | Named Constant |
---|---|
1 | ELEMENT_NODE |
2 | ATTRIBUTE_NODE |
3 | TEXT_NODE |
4 | CDATA_SECTION_NODE |
5 | ENTITY_REFERENCE_NODE |
6 | ENTITY_NODE |
7 | PROCESSING_INSTRUCTION_NODE |
8 | COMMENT_NODE |
9 | DOCUMENT_NODE |
10 | DOCUMENT_TYPE_NODE |
11 | DOCUMENT_FRAGMENT_NODE |
12 | NOTATION_NODE |