我正在 Internet Explorer(9、Windows 7 64 位)中打开一个 xml
文件。
Internet Explorer 喜欢以随机顺序显示元素属性,例如:
而不是声明的顺序:
<ApplicationVersion major="2" minor="2" release="12" build="687">2.2.12.687</ApplicationVersion>
例如:
或者
而不是:
是否有任何元素、属性、xml-dtd、xml-schema、Internet Explorer 选项、Windows 选项指示 IE 以声明的方式而不是随机顺序显示 XML?
最佳答案
属性按照 xml 标准的定义是无序的。
来自标准:
Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.
http://www.w3.org/TR/REC-xml/#sec-starttags
如果您需要属性的顺序,您将不得不更改您的标记。我建议如下:
<ApplicationVersion>
<attribute name="major">2</attribute>
<attribute name="minor">2</attribute>
<attribute name="build">687</attribute>
</ApplicationVersion>
链接:
Order of XML attributes after DOM processing
Can I enforce the order of XML attributes using a schema?
关于xml - Internet Explorer 以随机顺序显示 XML 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10317671/