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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -