Is there a way to match multiple elements in a tree using .findall()
?
I would like to do this:
trees = log.findall('element1' or 'element2')
This is my work around (which works in my case because I don't have both e1 and e2 in the same XML):
trees = log.findall('element1')
if not trees:
trees = log.findall('element2')
I am parsing XML files that have similar structures but different names. C# allows "element1 | element2" matching.
lxml
and uselxml.etree
in place of the stdlibxml.etree
? It often works as a drop-in replacement, and it offers a better answer here. – Gar