xml - Internet Explorer 以随机顺序显示 XML 属性

标签 xml internet-explorer internet-explorer-10

我正在 Internet Explorer(9、Windows 7 64 位)中打开一个 xml 文件。

Internet Explorer 喜欢以随机顺序显示元素属性,例如:

enter image description here

而不是声明的顺序:

<ApplicationVersion major="2" minor="2" release="12" build="687">2.2.12.687</ApplicationVersion>

例如:

enter image description here

或者

enter image description here

而不是:

enter image description here

是否有任何元素、属性、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/

相关文章:

html - 选择文本而不使用同级标记

c# - XML 命名空间让我感到困惑

java - 使用 SAX 的 XML 模式验证 - 它是如何工作的?

javascript - 无法解释为什么页面无法在 IE 中运行

javascript - 简单的 JavaScript/jQuery 不起作用

javascript - 附加事件以清除 IE10 文本框中的图标

java - Spring Boot REST 应用程序应该接受并生成 XML 和 JSON

javascript - Web worker 文件被缓存并且永远不会在 IE 11 中重新加载

javascript - IE 需要双击自定义按钮

javascript - IE10是否使用JScript 10.0