S
SM
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
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