元素节点和文本节点的区别

2022-01-10 00:00:00 xml xml-parsing dom java
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE people SYSTEM "validator.dtd">

<people>
    <student>
        <name>John</name>
        <course>Computer Technology</course>
        <semester>6</semester>
        <scheme>E</scheme>
    </student>

    <student>
        <name>Foo</name>
        <course>Industrial Electronics</course>
        <semester>6</semester>
        <scheme>E</scheme>
    </student>
</people>  

使用简单的 XML 语言 data </open-tag> 是一个元素.
根据我上面的 XML,<student>... </student> 是一个元素,其他标签也是如此.

In simple XML language <open-tag> data </open-tag> is an element.
As per my XML above, <student> ... </student> is an element and so are the other tags.

在DOM解析中,有一个Element节点和一个Text节点.参考我正在使用的书,<student>是一个Element节点和<name><course> 和其他嵌套标签是 Text 节点.

In DOM parsing, there is an Element node and a Text node. Referring to the book I am using, <student> is an Element node and <name>, <course> and the other nested tags are Text nodes.

所以,如果我正确理解 DOM,所有外部标签都是 Elements 而包含实际数据的标签是 Text 节点?

So, if I am understanding DOM properly, all the outer tags are Elements and the tags that contain the actual data are Text nodes ?

推荐答案

XML 中存在的所有 XML 元素都是一个元素节点.XML 元素中的文本是文本节点.

All the XML elements present in a XML is an element node. The text present in the XML elements are text nodes.

相关文章