Assign Integer Value to XML

Hi,
I need to assign a value to an XML file before I can use the file as input for further processing. I tired to achieve this using Replace functionality. However, it works only for String Variables and in my case it is Integer. If I don’t convert my String to Integer and then Set the Value, My Response is going into error. I’m getting following error if I pass String directly
For input string: "“3"”
Tried using following Approach
image

I’m attaching XML and my Project File. Kindly go thro and the same and let me know where I’m going wrong. Thanks In Advance

Hi,

Can you share your xml file and which value you need change?

Regards,

Thank you for the prompt Reply… Since I’m new to forum, system is not allowing me to upload any file… Trying to upload the same in drive.

Above one has Xml File

Thank you for the prompt Reply… Since I’m new to forum, system is not allowing me to upload any file… Tried to upload the same in Gdrive and still system doesn’t allow.

Hi,
PFA Zip File
TestProcessTemplate.zip (2.9 KB)
Also attaching XML File for your reference
Input.xml (421 Bytes)

I would like to set the highlighted Element with an integer value

Kindly Go thro it and let know your comments. Thanks

Integer. An integer defined in XML. Note: An integer is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine integer resources with other simple resources in the one XML file, under one element

Regards,
Will

@william_joe … Thanks for your reply. Can you share an example on how to achieve this? I’m still a beginner and an example would help me.

InputPayloadXml.Root.Descendants(vs+“jobInstanceID”).First().Value = YourValueAsString

with descendants you will 0,1, or more XElements. So we used First() (dependedn to your XML) and then set Value on the Value property

Tested on your XAML with a demo value:
grafik

Hi,

When we try to assign a String value, I don’t see any issues. But when I tried to convert the value to Integer and then assign, I’m facing the issue. In my case, I want to convert string to integer and then have to assign.

I’m using “Convert.ToInt32(Instance4)” to convert string to Integer. But system is throwing following error

image

Assign Activity is as below

image

To Variable Syntax That I’ve used in Assign Activity

“InputPayloadXml.Root.Descendants(vs+“jobInstanceID”).First().Value”

Let me know where I’m going wrong.

Regards,

XML Value is of String, as it is XML Data

Thanks @william_joe for your time and effort.

If I try to pass the value as String and tried to invoke Webservice, I’m getting faultsring error "For Intput String “3588"” in response payload as shown below in UI Path

PS: I’ve captured both Request and Response Payload in above picture.

However, If I copy the Request Payload generated and invoke the webservice from SOAP UI, it works perfectly well. So I thought it couldbe because of data type issue.
Kindly let me know if I’m doing anything not correct

Screeshot from SOAP UI

Regards,

Hi @william_joe ,

I think I got the issue… Issue was with some special Characters in one of my earlier Assign Activity.

I Changed expression to below

System.Text.RegularExpressions.Regex.Replace(Instance3,“[^0-9]”,“”)

Now it seems to be working… Thanks for your patience :slight_smile:

Regards

@ram_dhas

May we ask you to close the topic, Thanks
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.