To get attributes detail for following XML element
<catalog e="1" b="2" a="0">
I use NamedNodeMap
to get attribute, It is sorting the attributes as
a = 0, b = 2, e = 1
How can I print it as it is?
Attribute ordering is not a feature of DOM Level 3 which the Java type implements. See the W3C documentation for NamedNodeMap:
NamedNodeMap
s are not maintained in any particular order. Objects contained in an object implementingNamedNodeMap
may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of aNamedNodeMap
, and does not imply that the DOM specifies an order to these Nodes.
If you require this, the standard DOM is not what you are looking for.