开发者

How to encode a linebreak in XML

开发者 https://www.devze.com 2023-03-11 02:13 出处:网络
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

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>


needs to be CDATA:

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

精彩评论

暂无评论...
验证码 换一张
取 消