Commit a6530b84 authored by Patrick Shriwise's avatar Patrick Shriwise
Browse files

Quick function to report materials present in an ISOXML file

parent ca579289
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
import sys

from xml.etree import ElementTree as ET

def parse_isoxml(isoxml_file):
    tree = ET.parse(isoxml_file)
    root = tree.getroot()

    out_str = ""
    # find all "Isotope" elements
    isotopes = list(root.iter('Isotope'))
    out_str += f'Found {len(isotopes)} isotopes in the ISOXML:\n'
    for isotope in isotopes:
        out_str += f"\t{isotope.attrib['Name']}\n"

    return out_str

if __name__ == '__main__':
    print(f'Parsing XML file {sys.argv[1]}...')
    print(parse_isoxml(sys.argv[1]))