Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: CDATA vs Escaping XML Characters

From: "Anthony Jones" <Ant@------------.--->
To: NULL
Date: 6/2/2006 10:02:00 AM


"Julian F. Reschke" <julian.reschke@n...> wrote in message
news:ur7dtmhhGHA.4404@T......
> sudhakarnraju@g... schrieb:
> > Hi,
> > There's a need to generate xml documents in our project and in one of
> > the node, it can contain some snippets of code which can have <, > and
> > other xml symbols
> > e.g
> > <Code>
> > If i > 100 && j < 200
> > ...
> > End If
> > </Code>
> >
> > Question is: Should I XMLEncode the node text  ( &lt;, &gt; etc) OR
> > should I put them in CDATA attrib.
> >
> > Is there a difference between usage of the above 2 options. I beleive
> > they are part of same XML standard and are interoperable. Please confirm
>
> Confirmed.
>
> Hint: unless human readability of the XML is a major concern, I'd avoid
> CDATA altogether. It's just not needed and adds potential complexity
> (escaping of "]]>"...).
>

I think that depends on how the XML document is created.  If some form of
text editor is being used then in this case I would use CDATA as a matter of
course even if the current source snippet would be safe without one at this
time.

If the XML is machine generated then we can be confident that appropriate
entities are put in place of < and & so there is no need for CDATA.  Having
said that since CDATA is appropriate for this sort of content and not
personnaly ever having come across an example of a problem with the ]]>
terminator I'd still use a CDATA section.







transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent