Login   Register  
PHP Classes
elePHPant
Icontem

CDATA

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      RSS Writer class  >  All threads  >  CDATA  >  (Un) Subscribe thread alerts  
Subject:CDATA
Summary:Looking for a way of emitting a CDATA field
Messages:4
Author:Bernard Treves Brown
Date:2011-10-01 17:17:36
Update:2011-10-02 23:21:20
 

  1. CDATA   Reply   Report abuse  
Picture of Bernard Treves Brown
Bernard Treves Brown
2011-10-01 17:17:36
Hi
Is there a way of emitting CDATA?
I would like to use <content:encoded> tags in my feed.
Thanks
Bernard

  2. Re: CDATA   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2011-10-02 08:20:40 - In reply to message 1 from Bernard Treves Brown
Currently the XML writer class do not generate CDATA sections because usually it is not necessary. If you just add any data values the special characters ( <, >, " and control characters) will be encoded correctly.

Although I could add very quickly support to make certain tags have data as CDATA, I wonder if you really need it for some reason.

  3. Re: CDATA   Reply   Report abuse  
Picture of Bernard Treves Brown
Bernard Treves Brown
2011-10-02 19:38:31 - In reply to message 2 from Manuel Lemos
Hi

Thanks for your rapid reply.
I am trying to make my feed as standards-compliant as possible. As far as I can see the expectation is the <description> should be a short summary, preferably in plain text, while entire articles can appear in <content:encoded> normally using CDATA format with HTML markup.

I'm going by the advice from the validator at http://feedvalidator.org/about.html (which seems to give the same advice as http://validator.w3.org/feed/ )

Thanks again
Bernard

  4. Re: CDATA   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2011-10-02 23:21:20 - In reply to message 3 from Bernard Treves Brown
Well as far as I know you do not need to use CDATA sections to generate standards complaint XML.

CDATA is just a way to insert data in a document without having to encode it, as explained here:

http://en.wikipedia.org/wiki/CDATA

For instance:

<tag><![CDATA[
<html>
]]></tag>

is the same as:

<tag>&lt;html&gt;</tag>

The advantage of using CDATA sections is that you do not have to encode special characters like <, > and " .

Anyway, since the XML writer class encodes the data for you automatically when the document is generated, you do not need to use CDATA sections.