diff --git a/openmc/geometry.py b/openmc/geometry.py index 60f4a390d44..8815f2c8380 100644 --- a/openmc/geometry.py +++ b/openmc/geometry.py @@ -293,7 +293,8 @@ def from_xml( if isinstance(materials, (str, os.PathLike)): materials = openmc.Materials.from_xml(materials) - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() return cls.from_xml_element(root, materials) diff --git a/openmc/material.py b/openmc/material.py index 1f5496f15ea..d42c489aee0 100644 --- a/openmc/material.py +++ b/openmc/material.py @@ -1754,7 +1754,8 @@ def from_xml(cls, path: PathLike = 'materials.xml') -> Materials: Materials collection """ - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() return cls.from_xml_element(root) diff --git a/openmc/model/model.py b/openmc/model/model.py index a60960b2bad..5194fec1daa 100644 --- a/openmc/model/model.py +++ b/openmc/model/model.py @@ -253,7 +253,8 @@ def from_model_xml(cls, path='model.xml'): path : str or PathLike Path to model.xml file """ - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() model = cls() diff --git a/openmc/plots.py b/openmc/plots.py index b38b51a59c6..c73e3cdf73e 100644 --- a/openmc/plots.py +++ b/openmc/plots.py @@ -1508,6 +1508,7 @@ def from_xml(cls, path='plots.xml'): Plots collection """ - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() return cls.from_xml_element(root) diff --git a/openmc/settings.py b/openmc/settings.py index 6486d1f2a8e..a6d273901e0 100644 --- a/openmc/settings.py +++ b/openmc/settings.py @@ -1952,7 +1952,8 @@ def from_xml(cls, path: PathLike = 'settings.xml'): Settings object """ - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() meshes = _read_meshes(root) return cls.from_xml_element(root, meshes) diff --git a/openmc/tallies.py b/openmc/tallies.py index b6cd4d13939..ddc5d68ee6c 100644 --- a/openmc/tallies.py +++ b/openmc/tallies.py @@ -3304,6 +3304,7 @@ def from_xml(cls, path='tallies.xml'): Tallies object """ - tree = ET.parse(path) + parser = ET.XMLParser(huge_tree=True) + tree = ET.parse(path, parser=parser) root = tree.getroot() return cls.from_xml_element(root)