I have used DOMsorce
for XML
modification when i am writing modified data to a new file it is changing actual order of attributes(ascending order). so how to control this modification.
Asked
Active
Viewed 158 times
0

saravankg
- 909
- 1
- 10
- 21
-
how are you writing the data? – jtahlborn Oct 16 '13 at 12:50
-
It may help you [order-of-xml-attributes-after-dom-processing](http://stackoverflow.com/questions/726395/order-of-xml-attributes-after-dom-processing) – subodh Oct 16 '13 at 13:01
-
There's no significance to the order of attributes in XML - `` is the same as ``. – Ian Roberts Mar 19 '14 at 09:29
1 Answers
0
I have a quite similar problem. I need to have always the same attribute for first. Example :
<h50row a="1" xidx="1" c="1"></h50row>
<h50row a="2" b="2" xidx="2"></h50row>
must become
<h50row xidx="1" a="1" c="1"></h50row>
<h50row xidx="2" a="2" b="2"></h50row>
I found a solution with a regex:
test = "<h50row a=\"1\" xidx=\"1\" c=\"1\"></h50row>";
test = test.replaceAll("(<h5.*row)(.*)(.xidx=\"\\w*\")([^>]*)(>)", "$1$3$2$4$5");
Hope you find this usefull