问题
i am opening an xml
file in Internet Explorer (9, Windows 7 64-bit).
Internet Explorer likes to display element attributes in random order, e.g.:
rather than in declared order:
<ApplicationVersion major="2" minor="2" release="12" build="687">2.2.12.687</ApplicationVersion>
e.g.:
Or
rather than:
Is there an element, attribute, xml-dtd, xml-schema, Internet Explorer option, Windows option anywhere that will instruct IE to display the XML in declared, rather than random order?
回答1:
Attributes are unordered as defined by the xml standard.
from the standard:
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
If you require order in attributes you are going to have to change your markup. I suggest something like the following:
<ApplicationVersion>
<attribute name="major">2</attribute>
<attribute name="minor">2</attribute>
<attribute name="build">687</attribute>
</ApplicationVersion>
links:
Order of XML attributes after DOM processing
Can I enforce the order of XML attributes using a schema?
回答2:
Internet Explorer 11 also has this disappointing failure to xml display as written.
Use Chrome instead to display xml, it also has colour syntax highlighting.
来源:https://stackoverflow.com/questions/10317671/internet-explorer-displaying-xml-attributes-in-random-order