Posted: 4 Mar 2020 8:47 EST Last activity: 4 Mar 2020 12:37 EST
Read XML file using Global Dictionary
Is there a way to read the variables stored in a XML file from the Interaction.xml (Global Dictionary)?
I am going to be more specific: We are currently using an external XML file that stores soultion global variables that can potentially change during bots production deployment (e.g. email addresses, ip addresses, etc). Based on that, we need to use xml adapter to read every single variable. Is it possible to simply read ALL variables at once using Interaction.xml (Interaction XML recognizes at once all the variables defined in Global section and there's no need to use any adapter)
Note: We must keep Interaction.xml and ExternalFile.xml separated.
If you are more experienced as a developer, you can use the XML Component to read XML and traverse the hierarchy as you would in .Net. You can also write a script to do the same things if you are more comfortable there. If not, and you prefer to make this as easy as possible for newer Robotics developers, you can take advantage of the fact that the LookupTable component is built on top of a DataTable. A DataTable has native methods to read/write XML.
In the attached example, I created a LookupTable with whatever columns I wanted. You may edit this to suite your needs. I then export that to a file so that I have a file I can then edit. I can add my own values into the file now knowing the format that is required. In the example, I add some random data to the table on project startup, so that there's something in it to export and then edit.
One thing to keep in-mind, when you perform the Import, you want to clear the table first (if it is not already empty).In your production solution, you'd likely do this once on startup, so clearing the table wouldn't be necessary. I only do that here, so that we can see the data in the DataGridView (since the exporting of the data is really only something you'd do during development to get a copy of the XML file in the correct format).