I have an XML file which has a lot of different nodes with the same attribute.
I was wondering if it's possible to find all these nodes using Python and any additional package like minidom or ElementTree.
I have an XML file which has a lot of different nodes with the same attribute.
I was wondering if it's possible to find all these nodes using Python and any additional package like minidom or ElementTree.
This is a good sample/start script using xpath :
You can use built-in
xml.etree.ElementTree
module.If you want all elements that have a particular attribute regardless of the attribute values, you can use an xpath expression:
Or, if you care about values:
Example (using
findall()
method):Prints: