String Matching & Replacing

//Code to check the XML string and replace the value in another XML Tag. if (xml.ToLower().IndexOf("<subid>1") == -1) { string startTag = "<SID>"; string endTag = "</SID>"; int startTagLen = startTag.Length; int endTagLen = endTag.Length; int startTagIdx = xml.IndexOf(startTag); int endTagIdx = xml.IndexOf(endTag); string value = xml.Substring(startTagIdx + startTagLen, (endTagIdx - endTagLen) - startTagIdx + 1); xml = xml.Replace(startTag + value + endTag, startTag + "" + endTag); xml = xml.Replace("<MID>0000000000</MID>", "<MID>" + value + "</MID>"); }
Requirement was to match the value coming in XML request in QueryString and replace the value in another XML tag.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.