Wednesday, May 12, 2010

xml Node Types

Node Types

The following table lists the different W3C node types, and which node types they may have as children:

Node typeDescriptionChildren
DocumentRepresents the entire document (the root-node of the DOM tree)Element (max. one), ProcessingInstruction, Comment, DocumentType
DocumentFragmentRepresents a "lightweight" Document object, which can hold a portion of a documentElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
DocumentTypeProvides an interface to the entities defined for the documentNone
ProcessingInstructionRepresents a processing instructionNone
EntityReferenceRepresents an entity referenceElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
ElementRepresents an elementElement, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
AttrRepresents an attributeText, EntityReference
TextRepresents textual content in an element or attributeNone
CDATASectionRepresents a CDATA section in a document (text that will NOT be parsed by a parser)None
CommentRepresents a commentNone
EntityRepresents an entityElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
NotationRepresents a notation declared in the DTDNone

Node Types - Return Values

The following table lists what the nodeName and the nodeValue properties will return for each node type:

Node typenodeName returnsnodeValue returns
Document#documentnull
DocumentFragment#document fragmentnull
DocumentTypedoctype namenull
EntityReferenceentity reference namenull
Elementelement namenull
Attrattribute nameattribute value
ProcessingInstructiontargetcontent of node
Comment#commentcomment text
Text#textcontent of node
CDATASection#cdata-sectioncontent of node
Entityentity namenull
Notationnotation namenull

NodeTypes - Named Constants

NodeTypeNamed Constant
1ELEMENT_NODE
2ATTRIBUTE_NODE
3TEXT_NODE
4CDATA_SECTION_NODE
5ENTITY_REFERENCE_NODE
6ENTITY_NODE
7PROCESSING_INSTRUCTION_NODE
8COMMENT_NODE
9DOCUMENT_NODE
10DOCUMENT_TYPE_NODE
11DOCUMENT_FRAGMENT_NODE
12NOTATION_NODE

No comments: