Understanding the arguments for SubElement factory in ElementTree

mirandacascade at yahoo.com mirandacascade at yahoo.com
Sat Oct 29 08:39:34 CEST 2005


Can the **extra argument in the SubElement() factory in ElementTree be
used to set the text property? Example:

Want the text associated with the <subroot> tag to be xyz.

<root>
  <subroot>xyz</subroot>
</root>

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')




More information about the Python-list mailing list