在 XML 中,顺序重要吗? [英] In XML, is order important?

查看:39
本文介绍了在 XML 中,顺序重要吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

公共父元素在 XML 中出现的顺序是 XML 文档捕获的有意义的数据片段,还是未指定的顺序有意义?例如,考虑两个 XML 文档:

Is the order that elements of a common parent appear in XML a meaningful piece of data captured by the XML document, or is order not specified as being meaningful? For example, consider the two XML documents:

<people>
 <person name="sam"/>
 <person name="juni"/>
</people>

<people>
 <person name="juni"/>
 <person name="sam"/>
</people>

这些文档是否被视为代表相同的数据,或者是否捕获了顺序差异?

Are these documents considered to represent identical data, or is the difference in order captured?

推荐答案

元素的顺序在 XML 中很重要,因此在您的示例中,这两个文档是不同的.不过,属性顺序并不重要.

Order of elements is significant in XML, so in your example the two documents are different. Attribute order is not significant, though.

<people>
  <person name="kathy" id="1"/>
</people>

这与:

<people>
  <person id="1" name="kathy"/>
</people>

这篇关于在 XML 中,顺序重要吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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