Yarin
Yarin

Reputation: 183569

How to encode a linebreak in XML

I have XML elements that contain text with newlines but no other formatting. The text is being read by javascript and displayed in HTML. Is there an XML-safe way to encode the linebreak, or does this text need to be CDATA?

Example:

<sample>Here is a line <br>Here is another</sample>

Upvotes: 3

Views: 1454

Answers (1)

Chris Laarman
Chris Laarman

Reputation: 1589

needs to be CDATA:

<sample><![CDATA[Here is a line <br />Here is another]]></sample>

Upvotes: 4

Related Questions