[EMAIL PROTECTED] wrote:
>
> xyz
>
>
> rather than:
> root = Element('root')
> subroot = SubElement(root, 'subroot')
> subroot.text = 'xyz'
>
> Was wondering whether this code accomplish that
> root = Element('root')
> subroot = SubElement(root, 'subroot', text='xyz')
No, this creates:
Your SubElement call is lacking the attrib argument, but you can't set
text, anyway.
The elementtree source makes it clear, you can only set element attrib
attributes
with SubElement
def SubElement(parent, tag, attrib={}, **extra):
attrib = attrib.copy()
attrib.update(extra)
element =
Can the **extra argument in the SubElement() factory in ElementTree be
used to set the text property? Example:
Want the text associated with the tag to be xyz.
xyz
rather than:
root = Element('root')
subroot = SubElement(root, 'subroot')
subroot.text = 'xyz'
Was wondering whether this code