Sometimes, we want to parse XML with namespace in Python via ‘ElementTree’.
In this article, we’ll look at how to parse XML with namespace in Python via ‘ElementTree’.
How to parse XML with namespace in Python via ‘ElementTree’?
To parse XML with namespace in Python via ‘ElementTree’, we can use ther findall method.
For instance, we write
namespaces = {'owl': 'http://www.w3.org/2002/07/owl#'} 
root.findall('owl:Class', namespaces)
to call findall with 'owl:Class' and the namespaces dict with all the namespaces that we want to extract from the root XML object.
Conclusion
To parse XML with namespace in Python via ‘ElementTree’, we can use ther findall method.
 
							