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>
and
<people> <person name="juni"/> <person name="sam"/> </people>
Are these documents considered to represent identical data, or is the difference in order captured?
XML attributes are re-ordered alphabetically by the DOM parser. Attributes are being displayed in alphabetical order suggesting that the parser is sorting them.
Unlike with attributes, where order is insignificant according to the XML Recommendation: Note that the order of attribute specifications in a start-tag or empty-element tag is not significant. Element order is significant in XML.
The first line of an XML document should be a declaration that this is an XML document, including the version of XML being used.
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>
This is exactly the same as:
<people> <person id="1" name="kathy"/> </people>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With