当前位置: 首页 > 网络学院 > XML相关教程 > XML DOM > DOM 节点类型

XML DOM
DOM Attribute
DOM Text
DOM CDATA
DOM Comment
DOM HttpRequest
DOM ParseError
DOM 校验器
DOM 介绍
DOM 摘要
DOM 案例
DOM 节点树
DOM 访问节点树
DOM 节点信息
DOM 文档执行
DOM 节点导航

XML DOM 中的 DOM 节点类型


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1148 ::
收藏到网摘: n/a

The DOM presents a document as a hierarchy of node objects.
DOM是一个代表节点对象层次的文件。


Examples
案例

In the examples below, we will use the XML file books.xml, and the JavaScript function loadXMLDoc().
在下述案例中,我们会使用这两个XML文件:books.xml和JAVA函数loadXMLDoc()

Display nodeName and nodeType of all elements
显示所有元素中的“节点名称”和“节点类型”

Display nodeName and nodeValue of all elements
显示所有元素中的“节点名称”和“节点值”


Node Types
节点类型

The following table lists the different W3C node types, and which node types they may have as children:
下述表格列举了不同的W3C节点类型,每个节点类型中可能会包含子类:

Node type
节点类型
Description
描述
Children
子类
Document
文档
Represents the entire document (it is the root-node of the DOM tree)
定义整个文档(DOM树的根节点)
Element (max. one), ProcessingInstruction, Comment, DocumentType
DocumentFragment
文档片断
Represents a "lightweight" Document object, which can hold a portion of a document
定义“lightweight”文档对象(保留一个文档中的一部分)
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
DocumentType
文档类型
Represents a list of the entities that are defined for the document
定义文档的实体列表
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. Note: Attributes differ from the other node types because they are not considered child nodes of a parent
定义一个属性。
注意:属性和其它节点类型不同,因为它们不是同一个父节点的子节点。
Text, EntityReference
ProcessingInstruction
处理指令
Represents a "processing instruction"
定义一个“处理指令”
None
Comment
注释
Represents a comment
定义一个注释
None
Text
文本
Represents textual content (character data) in an element or attribute
定义一个元素或一个属性内的文本内容(字符数据)
None
CDATASection
CDATA部分
Represents a block of text that may contains characters that would otherwise be treated as markup
定义一块包含字符的文本区,这里的字符也可以是标记
None
Entity
实体
Represents an entity
定义一个实体
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
Notation
符号
Represents a notation declared in the DTD
定义一个在DTD中声明的符号
None

 


Node Types - Return Values
节点类型 — 返回值

Below is a list of what the nodeName and the nodeValue properties will return for each nodetype:
下面的列表详细定义了为每个节点类型(nodetype)所返回的节点属性(nodetype):

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部分
#cdata-section content of node
节点内容
Entity
实体
entity name
实体名称
null
Notation
符号
notation name
符号名称
null

 


NodeTypes - Named Constants
节点类型 – 指定常量

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

评论 (1) 1 All

登陆 | 还没注册?