Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internet Explorer displaying XML attributes in random order

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.:

enter image description here

rather than in declared order:

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

e.g.:

enter image description here

Or

enter image description here

rather than:

enter image description here

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?

like image 867
Ian Boyd Avatar asked Apr 25 '12 14:04

Ian Boyd


People also ask

Are XML attributes ordered?

According to the XML specification, the order of attribute specifications in a start-tag or empty-element tag is not significant. Please see the following link. Attributes can appear in any order. Native schema displays the attributes in alphabetical order.

Does XML maintain order?

XML element comparison by default preserves the order of elements in the two documents. A change of order will therefore result in elements appearing as added and deleted.

How do I view XML in Internet Explorer?

To view an XML file in Internet Explorer, you can specify a style sheet the following ways. Use the default style sheet, which presents the file as a collapsible tree. <? xml-stylesheet type="text/xsl" href="myfile.

Does order of elements matter in XML?

XML Specification Generally speaking, the order in which child elements appear inside their parent element container in XML shouldn't matter.


2 Answers

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?

like image 148
Colin D Avatar answered Oct 22 '22 03:10

Colin D


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.

like image 1
Chris Mills Avatar answered Oct 22 '22 02:10

Chris Mills