Mar-09-2022, 04:04 AM
(This post was last modified: Mar-09-2022, 04:05 AM by deanhystad.)
Or a Counter dictionary. That gets you all the types and a count of how many of each type.
Something like this:
Something like this:
Output:>>> from collections import Counter
>>> import xml.etree.ElementTree as ET
>>> xml_to_parse1 = ET.parse('/tmp/xmlfile.xml')
>>> get_xml = xml_to_parse1.getroot()
>>> disktypes = Counter([x.find('diskType') for x in get_xml.findall('physiccaldisk')])
>>> print(disktypes)