How to change the attribute valuep of xml using invoke code activity

please some ne help me on changing the attribute value of a xml string using invoke code activity.

below is the sample xml:
<soapenv:Envelope xmlns:soapenv=“” xmlns:rep=“” xmlns:mes=“”>
<ns0:abcdefgh xmlns:SOAP-ENV = “” xmlns:ns0 = “”>
<ns1:MessageHeader xmlns:ns1 = “”>

I want to modify the value of “FA”. please someone help me on this.

Thanks in Advance.

You can do that in two different ways @Venkat_Gandham

  1. Deserialize the XML and get the value of FA using for loop by looping through the names of nodes and then use innertext to change the value


  1. You can use string manipulations to replace the value within the string which is an easy way but not the standard way

could u please post the sample code for string manipulations

Please check the workflow directly to replace the value, but this is not the efficient way to replace in XML.

ReplaceStringBetweenTwoString.xaml (5.1 KB)

As @HareeshMR mentioned it might be good to have a look on alternates to regex

The Element FA you can retrieve via API e.g LINQ to XML and the a simple statement looks like:
xDoc.Root.Descendants(ns0 + “FA”).First()

And exactly on this part we have to pay attention on the important fact: XML is using Namespaces. This we do handle with an initialized XNamespace for xmlns:ns0=" and using it with ns0
The statement is fetching the first FA Descendent from Root Base (a like XPAth //FA[ X ]) X=Index

  • Setting the Value of FA Element can be done with the XElement.Method SetValue
  • Once we have changed the Value we do save the altered XML file, again with the XML Api.

There are alternates in place as well. But even this options (e.g. XPATH Statements) requires the correct referencing/usage of the relevant name space

Let us know your questions and feedback