views:

71

answers:

2

Here's the string:

\n\n\t\thttp://www.linkedin.com/in/ckenworthy\n\n\t

How can I strip everything so I only end up with:

http://www.linkedin.com/in/ckenworthy

I've tried the following:

string value = doc.XPathSelectElement("/ipb/profile/contactinformation/contact[title/text() = 'LinkedIn']/value").Value;
                value = value.Replace(Environment.NewLine, "");
                return value;

But I always end up with the first line I posted up there. Thank you!

+6  A: 

value.Trim() will probably do exactly what you want. It will remove all whitespace characters from the start and end of the string.

The reason Environment.NewLine may not work is because its value depends on whether you're running on Windows, Unix or Mac, but that really doesn't matter if you're getting the string from a remote system - the remote system will still return the same newline separator ('\n' in this case).

Evgeny
+3  A: 

Try...

value.Trim()
Rob