Hi all. I’m looking for the best way to handle my scenario.
I need to create a reusable activity to help us create XML files.
The idea is:
- Send in a data table (extracted from an excel sheet).
- Get the text from a template XML file
- Replace all variable names with the values of the matching column names from the data table
- Save as a new text file (could save as a string variable but I worry if it would be too long. I’m guessing that a text file would be safer).
I’m looking for help with point #3.
I could replace each xml variable name with the data table value but that will be very cumbersome to code (data table will have a lot of columns) and needlessly repetitive (there will be many templates to create this way).
There has to be a way to match the variable names with data table columns programmatically without having to write each one down, right?
Here’s a snippet of one of those xml files to illustrate:
<snx>
<unit id="${Unit}" category="${Category}" restow="NONE" transit-state="${T-state}" freight-kind="${FreightKind}" unique-key="${Unit}" line="${LineOp}">
${}
contain the variables. (these variables don’t have to be saved like that, I can change that format)
I have matching data table values and would get their values like this:
dt_testData.Rows(1).Columns(“Unit”).ToString
How can I loop through the file and replace all of those variables?