You can create an element or tree of elements from a
string containing XML with this function; it returns a
new Element instance representing all that XML.
etree.fromstring ( s )
where is a
string.
s
Here's an example:
>>> milne = '''<monster name='Heffalump'> ... <trail>Woozle</trail> ... <eeyore mood='boggy'/> ... </monster>''' >>> doc = etree.fromstring ( milne ) >>> print etree.tostring ( doc ) <monster name="Heffalump"> <trail>Woozle</trail> <eeyore mood="boggy"/> </monster> >>>