开发者

XML to preserve the whitespace

<?xml version="1.0"?>
<para>
<![CDATA[
gkjdfjg fdgsdfsdfdsf sdfdsfdsfsdfds fdsfdsfdsfsdfsd开发者_JS百科fd sdfsdf
sadf sdff sdf sdf

gkjdfjg fdgsdfsdfdsf sdfdsfdsfsdfds fdsfdsfdsfsdfsdfd sdfsdf
sadf sdff sdf sdf
]]>

</para>

I save this file as text.xml and try to view in browser. This return all text in one line !!! It is not preserving the content as defined in CDATA section ?.

I had read somewhere that XML preserve the white space then why it is not preserving the even if defined under CDATA section ?

Thanks


The browser displays it all on one line because browsers ignore whitespace. That is why you use <br /> tags (and others) in html to put in enters and white spaces.

So if you want to have a white line try this:

<?xml version="1.0"?>
<para>
<![CDATA[
gkjdfjg fdgsdfsdfdsf sdfdsfdsfsdfds fdsfdsfdsfsdfsdfd sdfsdf
sadf sdff sdf sdf
<br /><br />
gkjdfjg fdgsdfsdfdsf sdfdsfdsfsdfds fdsfdsfdsfsdfsdfd sdfsdf
sadf sdff sdf sdf
]]>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜