0

I have a string, containing XML namespace, and I cant seem to remove this part

xmlns="http://www.rar.org/xyz/"

I've tried

return textWriter.ToString().Replace(@"xmlns="http://www.rar.org/xyz/"", "");

but this does not compile.

John Koerner
  • 37,428
  • 8
  • 84
  • 134
Peter PitLock
  • 1,823
  • 7
  • 34
  • 71
  • 1
    What is the `textWriter` variable? If it is a `TextWriter` instance, then `ToString` isn't doing what you think that it is. It will return the name of the class, not the text, as it is inherited from the `Object` class. – Guffa May 14 '15 at 19:16

1 Answers1

2

You need to escape the string. Since you are providing a verbatim string literal (by using the @), you need to use two quotes to escape it:

return textWriter.ToString().Replace(@"xmlns=""http://www.rar.org/xyz/""", "");
John Koerner
  • 37,428
  • 8
  • 84
  • 134