Welcome to WebmasterWorld Guest from 54.205.115.177

Forum Moderators: httpwebwitch

Message Too Old, No Replies

Ampersands. HTMLencode, or CDATA?

a choice with nuances

   
7:08 pm on Jun 13, 2008 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



CDATA in attributes is forbidden.
Ampersands in attributes are forbidden.
Ampersands anywhere except CDATA are forbidden.
So if I have data that potentially contains an ampersand, I have two options:

this

<books>
<book title="Withnail &amp; I"/>
<book title="Griffin &amp; Sabine"/>
<book title="Love &amp; Marriage"/>
</books>

or this

<books>
<book><title><![CDATA[Withnail & I]]></title></book>
<book><title><![CDATA[Griffin & Sabine]]></title></book>
<book><title><![CDATA[Love & Marriage]]></title></book>
</books>

which would you choose?
and why?

10:31 am on Jun 14, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I use the first method which works for me without any problems.

Marshall

5:11 pm on Jun 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I ditto Marshall.