
Jan. 27, 2015
9:35 a.m.
Martin Mueller schrieb am 27.01.2015 um 16:48:
I want to move all attributes of an element to another element. If the attributes of elements x are x.attrib and attributes = x.attrib, is there a single command that says "take the attribute dictionary of x and attach it to y"?
Or do I have to use the .set method for each individual attribute?
element.attrib is a dict-like object, so you can use a.attrib.update(b.attrib). If you can't be sure that a.attrib is empty before you do that and don't want any left-over content, you can .clear() it first. Stefan