I have an xml file, similar to this:
<tag attrib1='I'>
<subtag1 subattrib1='1'>
<subtext>text1</subtext>
</subtag1>
<subtag3 subattrib3='3'>
<subtext>text3</subtext>
</subtag3>
</tag>
I would like to insert a new subElement, so the result would be something like this
<tag attrib1='I'>
<subtag1 subattrib1='1'>
<subtext>text1</subtext>
</subtag1>
<subtag2 subattrib2='2'>
<subtext>text2</subtext>
</subtag2>
<subtag3 subattrib3='3'>
<subtext>text3</subtext>
</subtag3>
</tag>
I can append my xml file, but then the new elements will be inserted at the end. How can I force python lxml to put it into a given position?
Thanks for your help!
See Question&Answers more detail:os