Encoding issues with XML_Feed_Parser
| From: | WebClaus | Date: | Mon, 25 Feb 2008 23:23:01 +0000 |
| Subject: | Encoding issues with XML_Feed_Parser | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-28576@lists.php.net to get a copy of this message | ||
Hi folks,
Trying to digest the feed available at http://www.thepost.ohiou.edu/rss.php?channel=1 I'm experiencing some problems with encoding.
Here's a ready to cut'n'paste example:
<?php
$url = 'http://www.thepost.ohiou.edu/rss.php?channel=1';
include_once('XML/Feed/Parser.php');
try {
$xfp = new XML_Feed_Parser(file_get_contents($url));
include_once('HTML/Page.php');
$page = new HTML_Page(array('charset' => 'utf-8'));
$page->addBodyContent('<dl>');
foreach($xfp as $item) {
$page->addBodyContent('<dt>' . $item->title() . '</dt><dd>' . $item->content() . '</dd>');
}
$page->addBodyContent('</dl>');
$page->display();
} catch( Exception $e ) {
die($e->getMessage());
}
?>
The content encoding that shows up on the page is screwed. I can do a __toString() on each item and see that the XML is preserved fine as UTF-8, so I'm thinking that XML_Feed_Parser is messing it up? Other feeds work fine, so can it be because of the xhtml divs used within the content elements?
Best,
Claus