xml - Adding sibling element in ElementTree with Python -


with xml such as

<a>   <b>   </b> </a> 

i need add sibling of like

<a>   <b>   </b>   <b'>   </b'> </a> 

does elementtree has function add sibling node? if not, guess need function parent node , add child node, how can that?

in standard lib's version, cannot directly access parent, you'll have work down parent, or keep track of parent-child relations yourself, read these tips (from author of library).

if use lxml however, there getparent() method (you have getnext() , getprevious() well), more convenient: there addnext() , addprevious().

so, choose 1 of these solutions, based on elementtree implementation using (or maybe switch implementation)


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -