I was hoping someone can help me with the following issue. As I am at a brick wall after a day on this.
I am trying to take products descriptions from an online shops database and produce an XML feed. The problem is the descriptions contain HTML so the XML breaks when viewing it in a browser
This is the line of code:-
echo '<DESCRIPTION>' . $row['products_description'] . '</DESCRIPTION>';
I have tried the following:-
echo '<DESCRIPTION><![CDATA[' . $row['products_description'] . ']]></DESCRIPTION>';
When i view the output it breaks the XML at the first
<BR>
I am aware of the htmlentities in PHP but this doesn't work as I pick up the XML from another shop to import the descriptions and they Wont display correctly when imported back in
I hope someone can help. Thanks for taking the time to look
Tidy the HTML first.
$config = array(
'indent' => true,
'output-xhtml' => true,
'wrap' => 200);
$tidy = new Tidy();
$tidy->parseString($row['products_description'], $config, 'utf8');
$tidy->cleanRepair();
echo '<DESCRIPTION>' . $tidy. '</DESCRIPTION>';
You will need to have the libtidy extension installed for this to work.