I would like to edit xml data for one element with in SOAP request in order to send unique SOAP requests.
Following is the example request
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"xmlns:web="http://webservice/">
<soapenv:Header/>
<soapenv:Body>
<web:ca>
<type1>
<ad>2013-07-19</ad>
<name>abcd 13071502</name>
<taker>
<taker>TEST</taker>
<emailAddress>[email protected]</emailAddress>
<name>nameTest</name>
<phoneNo>007007007</phoneNo>
<takerUid>1234</takerUid>
</taker>
</type1>
<type2>4</type2>
<type3>peace</type3>
<type4>test</type4>
</web:ca>
</soapenv:Body>
</soapenv:Envelope>
I would like to change "name" element value from "abcd 13071502" to "abcd ". I was able to extract data from "name" element and edit the value by using following code in C#
System.Xml.XmlTextReader xr = new XmlTextReader(@filePath);
while (xr.Read())
{
if (xr.LocalName == "name")
{
xr.Read();
currentNameValue = xr.Value;
int cnvLen = currentNameValue.Length;
string cnvWOdate = currentNameValue.Substring(0, cnvLen-8);
string newNameValue = cnvWOdate+currTimeDate;
break;
}
}
However, I couldn't figure out how to edit the value and save the file. Any help would be appreciated. Thank you.
new XmlTextReader()has been deprecated since .NET 2.0. UseXmlReader.Create()instead.