Modifying data values in an xml file

Hello, I am new to working with xml.
I am looking for guidance on my current project.
I have an commercial application that uses xml for data processing.
I want to pass information from excel to the xml files used by my application.
I have an Excel routine which creates one or more text files, each containing specific identification information.
I need to create an xml file with the identification information for each of the test files.
I have an xml file to use as template file with dummy information for each of the values in the text file.

I would like to accoimplish the following:

  1. Open the first text file.
  2. Open the template xml file.
  3. Replace the dummy information in the xml file with the information from the text file.
  4. Save the modified file with a new name to a specific network location.
  5. Repeat steps 1 through 4 for each of the remaining text files.

Any and all guidance will be greatly appreciated.

@displaced_texan_55

If the dummy information locations have tags like unique tags may be like <Replace1> etc then just read the xml as plain text and then use stringvariable.Replace("<Replace1>","Value to be replaced")

for renaming you can use copy file or rename file activities

reading text and xml can be done using read text file

cheers

Hi @displaced_texan_55
Welcome to UiPath,

use directory.getfiles to get text files, read each text file and xml template, replace dummy values using assign, write modified xml to network location, repeat using for each loop.

xmlUpdated = xmlTemplate.Replace(“DUMMY_ID”, extractedValueFromText)

If you found helpful, Mark as a solution tick .
Happy Automation

Are you needing to paste specific values from the text file or just replace the content of the xml file with the content of the text file?

  1. If paste specific values from the text file:
    a. Identify the values from text file using regex or split functions and save each value in a variable.
    b. Use a string.format function to paste each variable in the desired place in the XML template file.
  2. Paste the complete text file to XML:
    a. Any of the above mentioned methods should work.
    Let me know if you need help with the string.format method. Thanks!

Thank you. I’ll give this a try.

1 Like

Thanks. I’ll try this and post the outcome.

1 Like

Thanks. You’ve all given me good starting points.