
I have a "tail" problem with the following XML fragment <lg> <l>WHo doth desire the trump of fame, to sound vnto the Skies,</l> <l><pb/>Or els who seekes the holy place, where mighty Ioue he lies,</l> <l>He must not by deceitfull mind, nor yet by puissant strength,</l> </lg> I want to turn the <pb> tag from child to previous sibling of <l> and use this code for element in tree.iter(): if element.tag == 'pb': parent = element.getparent() grandparent = parent.getparent() position = grandparent.index(parent) parent.text = element.tail grandparent.insert(position , (element)) Some of it works but it fails to get rid of the pb tail and produces this output: <lg> <l>WHo doth desire the trump of same, to sound vnto the skies,</l> <pb/>Or els who seekes the holy place, where mighty Ioue he lies, <l>Or els who seekes the holy place, where mighty Ioue he lies,</l> <l>He must not by deceitfull mind, nor yet by puissant strength,</l> </lg> If there is a with_tail=False solution, I don't know where to stick the command. Martin Mueller Professor emeritus of English and Classics Northwestern University