For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > February 2008 > Encoding issues with XML_Feed_Parser









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Encoding issues with XML_Feed_Parser
WebClaus

2008-02-25, 7:09 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com