When I try and display text from an the InnerText from an XML element. I get something like this:
I need this spacing \r\n\r\n\r\second lot of spacing\r\n\r\nMore spacing\r\n\r\n
I know you can replace \r\n with <br> but is there no function that automatically takes the html for you and why does it use \r and \n? Many thanks.
You can use
<pre>tag – it will show the text as-is like you see it in text editor:For example:
Better practice for ASP.NET is:
Then assign its value from code behind:
As for your question “why does it use
\rand\n” those are carriage return and line feed characters, aka newline characters – when you have such text:Then code reading it will give:
line1\nline2orline1\r\nline2depending on how it’s stored exactly.