# Huge text node in model/settings XML file error

**URL:** <https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835>\
**Category:** User Support\
**Created:** [January 16, 2024, 7:06pm UTC](https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835 "2024-01-16T19:06:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://openmc.discourse.group/u/Edgar)\
**Post date:** [January 16, 2024, 7:06pm UTC](https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835/1 "2024-01-16T19:06:03Z")

</div>

Hello everyone!

Ran into an issue with a model xml that includes a large source mesh, ~1 million tets. If I write out to an XML settings.xml or model.xml then try to read it in, the parser aborts when it reaches the text node that defines the strengths. Unfortunately I can’t just run the model from the command line since it includes dagmc geometry. The error looks like this:

```auto
>>> import openmc
>>> settings = openmc.Settings.from_xml('settingsLi6_10.xml')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/dist-packages/openmc/settings.py", line 1955, in from_xml
    tree = ET.parse(path)
  File "src/lxml/etree.pyx", line 3541, in lxml.etree.parse
  File "src/lxml/parser.pxi", line 1879, in lxml.etree._parseDocument
  File "src/lxml/parser.pxi", line 1905, in lxml.etree._parseDocumentFromURL
  File "src/lxml/parser.pxi", line 1808, in lxml.etree._parseDocFromFile
  File "src/lxml/parser.pxi", line 1180, in lxml.etree._BaseParser._parseDocFromFile
  File "src/lxml/parser.pxi", line 618, in lxml.etree._ParserContext._handleParseResultDoc
  File "src/lxml/parser.pxi", line 728, in lxml.etree._handleParseResult
  File "src/lxml/parser.pxi", line 657, in lxml.etree._raiseParseError
  File "settingsLi6_10.xml", line 8
lxml.etree.XMLSyntaxError: xmlSAX2Characters: huge text node, line 8, column 10003731

```

Was wondering if there is a parameter I can pass somewhere to alleviate this or if it is a current limitation of OpenMC?

---

<div class="post-metadata">

**Author:** ![yrrepy](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/yrrepy/32/2365_2.png) [@yrrepy](https://openmc.discourse.group/u/yrrepy)\
**Post date:** [January 16, 2024, 8:02pm UTC](https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835/2 "2024-01-16T20:02:15Z")

</div>

Hi Edgar,  
I had the same issue, but with geometry.py

I submitted a pull-request

> <https://github.com/openmc-dev/openmc/pull/2791>
>
> \# Description
> Enabled lxml support for very deep trees and very long text conte…nt in the geometry Python class. (huge\_tree=true)
> 
> For large lattices with many elements (\>~500,000 elements) the Python Universe plotter would fail due to the "huge text node". With this change I can successfully universe.py plot my highly detailed voxel lattice.
> 
> The change implemented follows that counselled here:
> https://stackoverflow.com/questions/11850345/using-python-lxml-etree-for-huge-xml-files
> 
> Fixes:
> The error appearing during universe.py plotting was:
> \`\`\`
> Traceback (most recent call last):
> File "/home/abc/Projects/UniversePlotter.py", line 116, in \<module\>
> my\_geometry=openmc.Geometry.from\_xml();
> File "/home/abc/.local/lib/python3.10/site-packages/openmc/geometry.py", line 296, in from\_xml
> tree = ET.parse(path)
> File "src/lxml/etree.pyx", line 3541, in lxml.etree.parse
> File "src/lxml/parser.pxi", line 1879, in lxml.etree.\_parseDocument
> File "src/lxml/parser.pxi", line 1905, in lxml.etree.\_parseDocumentFromURL
> File "src/lxml/parser.pxi", line 1808, in lxml.etree.\_parseDocFromFile
> File "src/lxml/parser.pxi", line 1180, in lxml.etree.\_BaseParser.\_parseDocFromFile
> File "src/lxml/parser.pxi", line 618, in lxml.etree.\_ParserContext.\_handleParseResultDoc
> File "src/lxml/parser.pxi", line 728, in lxml.etree.\_handleParseResult
> File "src/lxml/parser.pxi", line 657, in lxml.etree.\_raiseParseError
> File "geometry.xml", line 435
> lxml.etree.XMLSyntaxError: xmlSAX2Characters: huge text node, line 435, column 10000881
> \`\`\`
> 
> 
> \# Checklist
> 
> \- \[x\] I have performed a self-review of my own code
> \- \[\] I have run \[clang-format\](https://docs.openmc.org/en/latest/devguide/styleguide.html#automatic-formatting) (version 15) on any C++ source files (if applicable)
> \- \[x\] I have followed the \[style guidelines\](https://docs.openmc.org/en/latest/devguide/styleguide.html#python) for Python source files (if applicable)
> ~- \[\] I have made corresponding changes to the documentation (if applicable)~
> ~- \[\] I have added tests that prove my fix is effective or that my feature works (if applicable)~

But haven’t gotten any takers yet ☹

I suspect you can take what I did there, adapt it to settings.py, compile, install.  
And it will work.

Probably a number of these Python files need the large text node correction.

Perry

---

<div class="post-metadata">

**Author:** ![paulromano](https://yyz2.discourse-cdn.com/free1/user_avatar/openmc.discourse.group/paulromano/32/486_2.png) [@paulromano](https://openmc.discourse.group/u/paulromano)\
**Post date:** [January 17, 2024, 6:53pm UTC](https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835/3 "2024-01-17T18:53:54Z")

</div>

Sorry @Edgar for the problem you’ve experienced here, and sorry to @yrrepy your PR didn’t receive attention sooner. It has now been merged into our main `develop` branch and should cover both of the problem cases (large geometry.xml file and large settings.xml file).

---

<div class="post-metadata">

**Author:** ![Edgar](https://avatars.discourse-cdn.com/v4/letter/e/b487fb/32.png) [@Edgar](https://openmc.discourse.group/u/Edgar)\
**Post date:** [January 17, 2024, 7:13pm UTC](https://openmc.discourse.group/t/huge-text-node-in-model-settings-xml-file-error/3835/4 "2024-01-17T19:13:08Z")

</div>

Awesome, I’ll check it out, thank you!
