Welcome to WebmasterWorld Guest from 54.196.232.162

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)

Moderator This Forum from CA 

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

joined:Aug 29, 2003
posts:4059
votes: 0


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 June 14, 2008 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member 10+ Year Member

joined:Sept 4, 2001
posts:2144
votes: 7


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

Marshall

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

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 21, 2005
posts: 1526
votes: 0


I ditto Marshall.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members