I want to add a subelement to an xml file, but in a very specific position, not appended to the end.
The standard way is:
subi = ET.SubElement(root[0][0], 'subi')
which is fine.
but: Let's say, root[0][0] already has two children, hence accessible via root[0][0][0] and root[0][0][1].
And I want "subi" to become the new middle child, root[0][0][1], making the original second child become the third child root[0][0][2].
Is there a way to do that? (My experiences with life and nature would say no, but I have high hopes for python=)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…