Replacing escape character?

  • Thread starter Thread starter Brett Romero
  • Start date Start date
B

Brett Romero

I have a string with the following XML and need to remove all of the
back slashes

"<ROOT><Person PersonId=\"56102\" /><Person PersonId=\"56104\"
/><Person PersonId=\"71266\" /></ROOT>"

I use

string newstring = cleanXML.Replace(@"\", "");

or

string newstring = cleanXML.Replace("\\", "");

But the back slashes remain. What is needed to remove them?

Thanks,
Brett
 
Brett Romero said:
I have a string with the following XML and need to remove all of the
back slashes

"<ROOT><Person PersonId=\"56102\" /><Person PersonId=\"56104\"
/><Person PersonId=\"71266\" /></ROOT>"

I use

string newstring = cleanXML.Replace(@"\", "");

or

string newstring = cleanXML.Replace("\\", "");

But the back slashes remain. What is needed to remove them?

Both of those will remove the backslashes. How are you determining that
the backslashes are there in the first place, and that they're there
afterwards? If it's by looking in the debugger, this may be confusing
you. See
http://www.pobox.com/~skeet/csharp/strings.html#debugger
 
Back
Top