To create or change an attribute named to value A in an VElement instance , use this method:
E
E.set (A,V)
Here's an example.
>>> node = etree.Element ( 'div', id='u401' ) >>> etree.tostring(node) '<div id="u401"/>' >>> node.set ( 'class', 'flyer' ) >>> etree.tostring(node) '<div id="u401" class="flyer"/>' >>> node.set ( 'class', 'broadside' ) >>> etree.tostring ( node ) '<div id="u401" class="broadside"/>' >>>
This method is one of two ways to create or change an
attribute value. The other method is to store values
into the .attrib dictionary of the Element instance.