I have a string containing XML data that is returned from an http request.
I am using ElementTree to parse the data, and I want to then search recursively for an element.
According to this question, I can only search recursively with result.findall()
if result
is of type ElementTree
rather than type Element
.
Now xml.etree.ElementTree.fromstring()
, used to parse the string, returns an Element
object, while xml.etree.ElementTree.parse()
, used to parse a file, returns an ElementTree
object.
My question is then: How can I parse the string and get an ElementTree
instance? (without any madness like writing to a temporary file)