Hello,
I have an XML file that looks like this
<?xml version="1.0" encoding="UTF-8"?>
<discography>
<CD>
<title>Moonligh t</title>
<year>1974</year>
<description>
<p>Descriptio n <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof the CD</p>
</description>
<item>
<track>Foreve r</track>
<track>Again</track>
<track>Alone</track>
</item>
</CD>
</discography>
The HTML output should look like this:
<h1>Moonlight </h1>
<h3>1974</h3>
<p>Descriptio n <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof 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
<descriptiontaq .
What should i do? Any suggestions?
Solution:
<description>
<![CDATA[
<p>Descriptio n <span>of</spanthe CD</p>
<p>More description of the CD</p>
<p>Another <b>paragraph</bof the CD</p>
]]>
</description>
Thanks in advance for all your advice
Marco
Comment