lxml - Python XML - appending multiple elements to multiple parents elegantly -
is there kind of more elegant way append elements parents parents need appended parents , on?
for example:
from lxml import etree root = etree.element('root') = etree.element('a') b = etree.element('b') c = etree.element('c') # append 1 one b.append(c) a.append(b) root.append(a)
maybe possible append of @ once? or need manually append in example?
you can define elements , "append" them in single go if you'd use subelement
:
root = etree.element('root') = etree.subelement(root, 'a') b = etree.subelement(a, 'b') c = etree.subelement(b, 'c')
Comments
Post a Comment