XML DOM 节点类型(Node Types)
节点类型
下面的表格列出了不同的 W3C 节点类型,以及它们可拥有的子元素:
| 节点类型 | 
描述 | 
子元素 | 
| Document | 
表示整个文档(DOM 树的根节点) | 
- Element (max. one)
 
- ProcessingInstruction
 
- Comment
 
- DocumentType
 
 
 | 
| DocumentFragment | 
表示轻量级的 Document 对象,其中容纳了一部分文档。 | 
- ProcessingInstruction
 
- Comment
 
- Text
 
- CDATASection
 
- EntityReference
 
 
 | 
| DocumentType | 
向为文档定义的实体提供接口。 | 
None | 
| ProcessingInstruction | 
表示处理指令。 | 
None | 
| EntityReference | 
表示实体引用元素。 | 
- ProcessingInstruction
 
- Comment
 
- Text
 
- CDATASection
 
- EntityReference
 
 
 | 
| Element | 
表示 element(元素)元素 | 
- Text
 
- Comment
 
- ProcessingInstruction
 
- CDATASection
 
- EntityReference
 
 
 | 
| Attr | 
表示属性。 | 
 | 
| Text | 
表示元素或属性中的文本内容。 | 
None | 
| CDATASection | 
表示文档中的 CDATA 区段(文本不会被解析器解析) | 
None | 
| Comment | 
表示注释。 | 
None | 
| Entity | 
表示实体。 | 
- ProcessingInstruction
 
- Comment
 
- Text
 
- CDATASection
 
- EntityReference
 
 
 | 
| Notation | 
表示在 DTD 中声明的符号。 | 
None | 
 
节点类型 - 所返回的值
下面的表格列出了对每个节点类型来说,nodeName 和 nodeValue 属性可返回的值:
| 节点类型 | 
nodeName 的返回值 | 
nodeValue 的返回值 | 
	| Document | 
	#document | 
	null | 
	| DocumentFragment | 
	#document fragment | 
	null | 
	| DocumentType | 
	doctype 名称 | 
	null | 
	| EntityReference | 
	实体引用名称 | 
	null | 
	| Element | 
	element name | 
	null | 
	| Attr | 
	属性名称 | 
	属性值 | 
	| ProcessingInstruction | 
	target | 
	节点的内容 | 
	| Comment | 
	#comment | 
	注释文本 | 
	| Text | 
	#text | 
	节点内容 | 
	| CDATASection | 
	#cdata-section | 
	节点内容 | 
	| Entity | 
	实体名称 | 
	null | 
	| Notation | 
	符号名称 | 
	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 |