AnttiS
(Batman)
November 29, 2021, 8:28am
1
Hi everyone
Can you help pls; I want to read cells from Excel and use cell content to replace a predefined XML tag content with those.
So, if I have an Excel cell with content: “myname@domain.com ”, I want to use that string in a readymade XML like:
(Original tag)
emailadress@here.com to
(cell from excel)
myname@domain.com
The current problem is that I do not know how to write into XML those values so that the XML keeps it integrity.
I have already Uipath reading excel and assigning cells to variables ok. How I can out those into predefined XML replacing original tag content?
Any ideas, folks?
ppr
(Peter Preuss)
November 29, 2021, 8:41am
2
please use </> format button from editor when sharing XML snippets. If possible share the entire XML as file with us. thanks
AnttiS
(Batman)
November 29, 2021, 9:57am
3
I can´t share the actual code but this is the basic idea. Thanks for noticing, I corrected the original post to show the tags…
ppr
(Peter Preuss)
November 29, 2021, 10:08am
4
not sure, if the corrected XML was formated. However in general at least two options are available.
String Replacement on Placeholders
Define a text template with placeholders <abc><email>#EMAIL#</email></abc>
read in the template (e.g. from a textfile) or use the string
Do the replacement: myTemplateString.Replace(“email ”, strValueFromExcel)
XML Approach
deserialize XML with the Deserialize XML Activity from UiPath.WebApi.Activities Package
grab the element
replace the value
1 Like
AnttiS
(Batman)
November 29, 2021, 10:23am
5
Thanks, I will try that. I already tried to edit a text file with variables. But not with this way.
AnttiS
(Batman)
November 30, 2021, 2:12pm
6
Yeah, String replacement with placeholders was the thing.
I made a text template in directory NN. Content is in XML format and tags have placeholders.
Then I read the excel file & convert it cells to variables. Then I read that text file in.
Then “replacing text” with variables. Then saved the result text as a XML in target directory. Couldn´t be more simple.
At first I overthinked and tried to use “create HTML content”. What a mess that was ;-D
Thanks @ppr for advise, much appriciated!
system
(system)
Closed
December 3, 2021, 2:13pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.