XML 中的根节点、根元素和文档元素有什么区别? [英] What is the difference between root node, root element and document element in XML?

查看:55
本文介绍了XML 中的根节点、根元素和文档元素有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 W3C XML 路径语言 (XPath)版本 1.0 第 5.1 节 根节点

<块引用>

根节点是树的根.除了作为树的根之外,不会出现根节点.文档元素的元素节点是根节点的子节点.根节点还有作为子节点的处理指令和注释节点,用于处理出现在序言中和文档元素结束之后的指令和注释.

我对根节点文档元素以及人们有时使用的根元素感到困惑.>

如果我有一个像这样的简单 XML 文档:

<b1><c></c></b1><b2></b2></a>

什么是根节点、根元素和文档元素?那些都是吗?

在你的 XML 中:

I am reading W3C XML Path Language (XPath) Version 1.0 Section 5.1 Root Node,

The root node is the root of the tree. A root node does not occur except as the root of the tree. The element node for the document element is a child of the root node. The root node also has as children processing instruction and comment nodes for processing instructions and comments that occur in the prolog and after the end of the document element.

and I'm confused about the root node, document element terminologies, as well as root element that sometimes people use.

If I have a simple XML doc like this:

<a>
    <b1>
        <c></c>
    </b1>

    <b2></b2>
</a>

What is the root node, root element and document element? Are those all <a>?

解决方案

In your XML:

  • a is the document element, sometimes called the root element, which is selected via /a.
  • The parent of a is the document's root node, which is selected via /.

这篇关于XML 中的根节点、根元素和文档元素有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆