When writing in java the following:
Element fieldEl = targetDocument.createElement("field");
fieldEl.setAttribute("Wine","Marlo");
fieldEl.setAttribute("Beer","Corona");
The order of adding the attributes are not kept in the result XML file.
How can I control the order of the attribute inside XML Element (so it will be easy for human being to read…) ??
There is no defined order for attribute nodes according to the DOM standard:
(emphasis added) and neither in the XML standard:
I don’t think, that many DOM implementations support ordering of attributes at all. You’d have to write your own serialization mechanism in order to achieve ordering (no pun intended).