Need advice: What is the best way; CDATA or normal xml tag





Hello,
I have an XML file that looks like this

<?xml version="1.0" encoding="UTF-8"?>
<discography>
<CD>
<title>Moonlight</title>
<year>1974</year>

<description>
<p>Description <span>of</span> the CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</b> of the CD</p>
</description>

<item>
<track>Forever</track>
<track>Again</track>
<track>Alone</track>
</item>
</CD>
</discography>

The HTML output should look like this:

<h1>Moonlight</h1>
<h3>1974</h3>

<p>Description <span>of</span> the CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</b> of the CD</p>

<ul>
<li>Forever</li>
<li>Again</li>
<li>Alone</li>
</ul>

I've manage to create the HTML but i'm stock with the xml
<description>.
I found a solution using CDATA, but i'm not sure if it's an elegant
solution. I've read that the CDATA was not ment to be used for that
purpose.

As a programmer, i always try to create code that is ok and elegant.

But in this case, the CDATA works perfectly and it's so simple. I feel
like if don't use the CDATA solution i would need to create a
complicated function to extract all those HTML tags inside the xml
<description> taq.

What should i do? Any suggestions?


Solution:
<description>
<![CDATA[
<p>Description <span>of</span> the CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</b> of the CD</p>
]]>
</description>

Thanks in advance for all your advice
Marco
.



Relevant Pages

  • Re: CDATA & FOR XML PATH
    ... to be rendered as html when producing an xslt transformation. ... for xml path, root ... How can I ensure the both the html and the element containing the cdata are ... >> Using a nested FOR XML EXPLICIT statement within an FOR XML PATH query is ...
    (microsoft.public.sqlserver.xml)
  • Re: xml cdata
    ... Non-wellformed HTML will have to be entitized when you include it into XML. ... The CDATA section is only one of several syntactic ways of achieving that... ... FOR XML decided to entitize HTML data. ...
    (microsoft.public.sqlserver.xml)
  • Re: XML CDATA etc
    ... I am getting some information from DB, and that data has mix html and XML tags in the content. ... Basically CDATA types are mixed with regular string. ...
    (microsoft.public.dotnet.xml)
  • Re: xml cdata
    ... why do you have to store the HTML inside XML? ... How can I get the cdata out? ...
    (microsoft.public.sqlserver.xml)
  • Re: onclick - reassign new function with parameters after displaye
    ... It creates an HTML document which looks and acts correctly. ... The orginal XSL is creating a record that shows data from two different ... The form reads in those global variables. ... XML Node that forms the context of your little XSL. ...
    (microsoft.public.scripting.jscript)