# Document Tag to Store XML File

**URL:** <https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [March 28, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394 "2025-03-28T17:42:23Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [March 28, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/1 "2025-03-28T17:42:23Z")

</div>

I have not used the document tag type yet. Wondering if it would be appropriate to use it to store XML file data.

If yes:

1. How would I read/write the document tag?
2. Is the resulting document tag able to be read and parsed by python?

If no:

1. What would be the best route to store an XML file as part of the gateway (i.e. not read from the gateway's file system).

The intention here would be to have a download current/upload new XML document button on a page to get the current XML document tag(s) or write a new XML file to the document tag. And then, of course do something on the gateway with that XML file.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 28, 2025, 6:12pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/2 "2025-03-28T18:12:25Z")

</div>

No.

1. Parse the XML into a DOM, and then, for each node make a dictionary holding a type value, an attributes dictionary, and a nested nodes list. Save that into the document tag instead--it will be jsonified.

Good luck.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2025, 6:14pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/3 "2025-03-28T18:14:44Z")

</div>

"Document" should have been "JSON". I'll upset myself if I get into why it's called "Document" instead of "JSON" too much, just know I argued against it 🥲

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [March 28, 2025, 6:50pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/4 "2025-03-28T18:50:00Z")

</div>

> [@pturmel](#):
>
> Good luck.

Sounds like I'll need it.

What's a DOM ?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 28, 2025, 6:52pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/5 "2025-03-28T18:52:01Z")

</div>

Document Object Model. There should be some native java libraries for dealing with these.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [March 28, 2025, 6:55pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/6 "2025-03-28T18:55:44Z")

</div>

In this case the XML files will be consistently formatted.

Maybe another option would be to parse the XML on upload into a string array tag? Is there a limitation to the length of a string? - might run into that.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 28, 2025, 6:59pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/7 "2025-03-28T18:59:01Z")

</div>

> [@Text datatype for tag](https://forum.inductiveautomation.com/t/text-datatype-for-tag/44582/6):
>
> If you’re using a memory tag then there actually is some limitation on the size. The entire tag configuration is stored as a JSON string that is limited to 268,435,455 bytes (0x0FFFFFFFF). A very large String value could push it over that limit.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [March 28, 2025, 7:01pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/8 "2025-03-28T19:01:18Z")

</div>

Considering that one example file in it's entirety is 548k characters, ~~I'm probably safe~~ I would be safe if the tag was one string. An array of strings maybe not.

Does a string array tag have the same 268,435,455 byte limitation?

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 28, 2025, 7:07pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/9 "2025-03-28T19:07:25Z")

</div>

I'm guessing you are actively doing something with the XML file that prevents you from storing it in the db as blob?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [March 28, 2025, 7:07pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/10 "2025-03-28T19:07:51Z")

</div>

Don't put these into string tags.

XML documents this size should remain as files.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [March 28, 2025, 7:12pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/11 "2025-03-28T19:12:46Z")

</div>

Yes.

I will read in portions of the XML file, make substitutions and then ultimately make a new XML file for export based on the imported file.

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [March 28, 2025, 7:14pm UTC](https://forum.inductiveautomation.com/t/document-tag-to-store-xml-file/104394/12 "2025-03-28T19:14:05Z")

</div>

Definitely keep it as a file. On upload, transfer a backup copy to somewhere on the gateway filesystem (we made a folder that only Ignition can touch), and then read it into memory to start making changes.

After you're done, you can delete the file or retain it for a period of time.
