Hello,
I'm trying to generate a RSS newsfeed using the DOM XML functions. However I
can't find a way to use accentuated characters. I even tried to specify a
character encoding set but it doesn't solve the problem.
Error I get :
XML Parsing Error: not well-formed
Location: news.php?action=syndicate&format=rss2
Line Number 1, Column 102:<?xml version="1.0" encoding="ISO-8859-15"?><rss
version="2.0"><channel><title>Website title - News (
----------------------------------------------------------------------------
-----------------------------------------------------------^
The not well-formed character is an accentuated character, as you can see on
the following code sample :
<?php
header ('content-type: text/xml');
echo ('<?xml version="1.0" encoding="ISO-8859-15"?>');
$dom_doc = domxml_new_doc ('1.0');
$rss_el = $dom_doc->create_element ('rss');
$rss_el->set_attribute ('version', '2.0');
$rss_el = $dom_doc->append_child ($rss_el);
$channel_el = $dom_doc->create_element ('channel');
$channel_el = $rss_el->append_child ($channel_el);
$title_el = $dom_doc->create_element ('title');
$title_el = $channel_el->append_child ($title_el);
$title_el->set_content ('Website title - News (àéèù)');
echo ($dom_doc->html_dump_mem ());
?>
Removing the accentuated characters from the title generates a well formed
XML file. Note that I also tried to encode the characters using the
htmlentities function but it didn't change anything.
--
Jean-Marc.