Reputation: 25938
I am parsing a html file for one simple line. So I am not using a 3rd party library just normal string functions(s.subString()
etc.).
My problem is I cannot correctly find specific elements in the HTML because they contain tab characters, endlines, carriage returns.
How can I print the following string to display all the carriage returns as \r, all endlines as \n & etc. So I can then see exactly the layout of the HTML file & ensure my
.subString("<div class=\"x\">")
is not failing because the text is really
("<div \t\r\nclass=\"x\">"
or something?
My code:
WebClient wc = new WebClient();
string html = wc.DownloadString(String.Format("http://www.ipchecking.com/?ip={0}&check=Lookup", ip));
Console.Write( html ); // I want to print in the raw form where \r characters are actually shown as \r characters
Upvotes: 1
Views: 1658
Reputation: 9158
html = html.Replace("\r", "\\r").Replace("\n","\\n").Replace("\t","\\t");
Upvotes: 4