I am using element tree with python to perse xml file. I am only inserting new nodes after a certain node. I am not modifying any attributes. The logic works fine and the new nodes get added to the proper places. But the in the output the positions of the attributes of the nodes are getting interchanged as shown below:
Input
<set title="Set Testcase1 to 128">
<testvariable name="Testcase1" msg="TEST" node="TESTER" testtype="METHOD1">128</testvariable>
</set>
<match **title="match" timeout="220"**>
<testvariable name="Testcase1" msg="TEST" node="TESTER" **testtype="METHOD1"**>128</testvariable>
</match>
Output
<set title="Set Testcase1 to 128">
<testvariable testtype="METHOD1" msg="TEST" name="Testcase1" node="TESTER">128</testvariable>
</set>
<match timeout="220" title="match">
<testvariable testtype="METHOD1" msg="TEST" name="Testcase1" node="TESTER">128</testvariable>
</match>
The write to output is done using:
tree.write(r'textOut.xml',encoding="iso-8859-1")
.
Anyone please let me know why the attributes place get interchanged.
Thanking you in advance.