I was looking to represent a carriage return within an xml node.
I have tried a whitespace preserve, hex entity with no luck- and a \n. viewing via a browser.
Example
<Quote> Alas, poor Yorick! I knew him </Quote>
Thanks.
Yes, is LF, is CR. Windows world usually has CRLF sequences (that is ), Linux has just LF ( ). OMG, thank you sooooo much!
You can use 
 for line feed (LF) or 
 for carriage return (CR), and an XML parser will replace it with the respective character when handing off the parsed text to an application.
Write content in separate tags as this will result in a line break. Also try using \n or \r. Here is the answer from stackoverflow.com https://stackoverflow.com/questions/35504890/how-to-add-a-newline-line-break-in-xml-file Scroll down to the part with cdata. That should be the answer you want.
It's generally considered bad practice to rely on linebreaks, since it's a fragile way to differentiate data. While most XML processors will preserve any whitespace you put in your XML, it's not guaranteed.
To insert a CR into XML, you need to use its character entity
.
This is because compliant XML parsers must, before parsing, translate CRLF and any CR not followed by a LF to a single LF. This behavior is defined in the End-of-Line handling section of the XML 1.0 specification.
xml:space="preserve"
has to work for all compliant XML parsers.
However, note that in HTML the line break is just whitespace and NOT a line break (this is represented with the <br />
(X)HTML tag, maybe this is the problem which you are facing.
You can also add
and/or
to insert CR/LF characters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With