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
Post a Comment