I am having XML in a String as below
String s = @<user>abc.int\abhi</user>
but when i write the following code
XmlDocument doc = new XmlDocument();
doc.InnerXml = s;
XmlElement root = doc.DocumentElement;
String User = root.SelectSingleNode("user");
The User has the value abc.int\\abhi instead of abc.int\abhi the ‘\’ character appears twice in the string.
Thank you in advance.
Do you check that value in VS watch window? If so, it is normal to display \, because watch window shows string as if it was written in code, not the real string.
In code, if you want to enter \ into a string, you have to write
string s = "\\";And this will create actual string with \ in it.try outputting your string to console or messagebox, and you should see, that it is correct.