XML and CDATA

Associate
Joined
7 Jul 2003
Posts
1,749
Location
oh I do like to be beside the seaside
Which is these is the correct use of CDATA in XML?

Code:
<![CDATA[<AddressLine1>1 Arcacia Avenue</AddressLine1>]]>

or

Code:
<AddressLine1><![CDATA[1 Arcacia Avenue]]></AddressLine1>

I'm thinking it's the 2nd one as the tags are outside of the CDATA, whereas in the first one the tags are inside and so will just be treated as text

Thanks.
 
CDATA inside the tags.
Technically both are valid, it depends what you want to achieve - inside the tags is more common though.
 
Last edited:
Back
Top Bottom