你总是必须有一个带有 xml/xsd 的根节点吗? [英] Do you always have to have a root node with xml/xsd?

查看:34
本文介绍了你总是必须有一个带有 xml/xsd 的根节点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一直在看教程,它有以下 xml 和 xsd.:

Been looking at a tutorial and it has the following xml and xsd.:

我想知道在这个例子中你是否必须使用根节点?似乎没有任何指向 'employeeS' 节点的 xsd 类型定义.

What I was wondering is do you have to use a root node in this example? There doesnt seem to be any xsd type definition that points to the 'employeeS' node.

你是否总是必须在 xml 中有一个根节点,或者你可以只有

Do you always have to have a root node in xml or can you just have

<xml version="1.0">
<employee><employee>
<employee><employee>
<employee><employee>

推荐答案

来自 http://www 的 XML 规范.w3.org/TR/REC-xml/(第五版)第二章

from the XML specification at http://www.w3.org/TR/REC-xml/ (fifth edition) chapter 2

这是说

每个 XML 文档都具有逻辑和物理结构.从物理上讲,文档由称为实体的单元组成.一个实体可以引用其他实体以导致它们包含在文档中.文档以根"开始或文档实体."

"Each XML document has both a logical and a physical structure. Physically, the document is composed of units called entities. An entity may refer to other entities to cause their inclusion in the document. A document begins in a "root" or document entity."

"[定义:只有一个元素,称为根元素或文档元素,其中没有任何部分出现在任何其他元素的内容中.] 对于所有其他元素,如果开始标记在另一个元素,结束标签位于同一元素的内容中.更简单地说,由开始和结束标签分隔的元素相互嵌套."

"[Definition: There is exactly one element, called the root, or document element, no part of which appears in the content of any other element.] For all other elements, if the start-tag is in the content of another element, the end-tag is in the content of the same element. More simply stated, the elements, delimited by start- and end-tags, nest properly within each other."

所以基本上是的,你总是需要一个根元素.

So basically yes, you always need one root element.

这篇关于你总是必须有一个带有 xml/xsd 的根节点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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