How do I remove a node in xml using ElementTree in Python?

wunder

New Member
I've read the \[code\]remove\[/code\] example here and the example here is not applicable to me.My xml file reads:\[code\]<A> <B>some text</B> <B>other text</B> <B>more text</B></A>\[/code\]What I want to do is to remove the second \[code\]<B></B>\[/code\] from the xml. I do not know what text it holds. But I have the index of the \[code\]<B></B>\[/code\], say index = 1, which means I want to remove the second element (or node).I have a code like this:\[code\]F = open('example.xml')self.tree = parse(F)self.root = self.tree.getroot()F.close()\[/code\]So in this case what I want to remove is \[code\]self.root[1]\[/code\].How can this be implemented using ElementTree?Edit: Made my question more clear and specific.
 
Back
Top