How to correctly write xml document with spaces and new lines inside using CDATA? -


<?xml version="1.0" encoding="utf-8" standalone="yes"?> <codecases>   <case1>     <codetext>       <![cdata[ for(var i=0;  i;10;i++) {       var x; } ]]>     </codetext>   </case1> </codecases> 

this code i'm using, however, when open in browser, doesn't read new lines. doing wrong?

with cdata, new lines preserved. issue in case isn't that. if @ source of generated html file (in firefox, via view -> page source or ctrl+u) you'll see new lines preserved in text. i've tried cdata section myself (via xslt processing).

what happened in case browser doesn't care raw new lines, , multiple white-space added in html files.

to maintain formatting of text, need wrap content white-space css property set pre

ie, html content like,

<div style="white-space:pre;"> for(var i=0;  i;10;i++) {       var x; } </div> 

usual way of maintaining line breaks adding <br> tags. doesn't apply here.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -