dbol Posted June 8, 2010 Share Posted June 8, 2010 I cannot seem to parse special characters correctly. I tried passing it through a converter (iconv) to encode in UTF-8, but it doesn't help. My XML file is as follows: <rss version="2.0"> <channel> <item> <title>Email: Deval Patrick premium caps could cause &#x2018;train wreck&#x2019; - BostonHerald.com</title> <link>http://news.bostonherald.com/business/healthcare/view/20100608email_deval_patrick_premium_caps_could_cause_train_wreck/srvc=home&#x26;amp;position=recent</link> <description>BOSTON &#x2014; A top state insurance official said that health insurance caps the Patrick administration placed on major insurers could cripple them financially and would most likely cause &#x22;a train wreck,&#x22; according to an email obtained Tuesday by The Associated...</description> <pubDate>Tue, 08 Jun 2010 20:56:52 GMT</pubDate> <source url="http://news.bostonherald.com/">BostonHerald.com</source> </item> </channel> </rss> My PHP is as follows: <?php $incoming = file_get_contents("parsexml.xml"); $simplexml= iconv( "UTF-8", "ISO-8859-1//TRANSLIT", $incoming); $simplexml = simplexml_load_string($simplexml); $items = $simplexml->channel->item; ?> <html> <head> <title>Parse Special Chars</title> </head> <body bgcolor="#FFFFFF"> <center><h1>Title</h1></center> <br/> <table align="center"> <tr> <td width="600"> <?php foreach ($items as $item){ echo "<b>" . $item->title . "</b><br/>"; } ?> </tr> </td> </tr> </table> </body> </html> Notice the title has odd characters around 'train wreck' where there should be apostrophes. I've also attached both the xml and php file for convenience. Thanks. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/204232-strange-characters-not-decoding-correctly/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.