Save and load weight window as xml

Hello,

I have been working with developing weight windows for deep shielding problems.

The actual process of creating the window is fine but I’m struggling to save and load it as an xml-file. I haven’t worked with xml-files before so it’s all new to me.

I use this to save my weight_window:

xml_element = weight_window.to_xml_element()
tree = ET.ElementTree(xml_element)
tree.write(xml_path)

Which does save it to an xml-file.

Then I try to load it and create my weight window using this:

tree = ET.parse(xml_path)
root = tree.getroot()

weight_window = openmc.WeightWindows.from_xml_element(tree, root)

But I get this error when I run the from_xml_element()-method:

AttributeError: 'ElementTree' object has no attribute 'attrib'

Which makes me think I’ve done something wrong with the loading process and when I’m using the from_xml_element(). Do I need to initiate the WeightWindows-object with the mesh first? The two required arguments are mesh and lower_bounds but of course the lower_bounds I get from the saved_xml-file so I’m a bit confused.

I would greatly appreciate any help on this!