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:
How would I read/write the document tag?
Is the resulting document tag able to be read and parsed by python?
If no:
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.
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.
"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
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.
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?
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.