simplexml_load_string() error when loading XML content from Twitter
Posted on: September 6th, 2009
If you are constantly receiving the following error when trying to run simplexml_load_string() to get XML content from Twitter or other, load the xml via file_get_contents() instead of directly into a SimpleXML object (see my example below).
Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 10: parser error : Opening and ending tag mismatch: META line 8 and HEAD in/home/vhosts/5000135504/simra.ch/htdocs/simra_2/widgets/twitter.phpon line 17Warning: simplexml_load_string() [function.simplexml-load-string]: </HEAD> in/home/vhosts/5000135504/simra.ch/htdocs/simra_2/widgets/twitter.phpon line 17Warning: simplexml_load_string() [function.simplexml-load-string]: ^ in/home/vhosts/5000135504/simra.ch/htdocs/simra_2/widgets/twitter.phpon line 17Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 11: parser error : Opening and ending tag mismatch: P line 11 and BODY in/home/vhosts/5000135504/simra.ch/htdocs/simra_2/widgets/twitter.phpon line 17and so on....
<?php$feed = file_get_contents("http://twitter.com/statuses/user_timeline/55789790.rss");$feed = iconv("UTF-8","UTF-8//IGNORE",$feed);$feedData = simplexml_load_string($feed);foreach ($feedData->channel as $channels) {echo '<ul>';$c=0;foreach($channels->item as $entry){echo "<li style='border-bottom: 1px dotted #D2E8F7;margin-bottom:15px;list-style: none;'>$entry->title";echo "<br /><p align='right' style='color:#848484;font-size:9px;'>".date('d.m.y H:i:s', strtotime($entry->pubDate))."</p>";echo "</li>";$c++;if($c==4){break;}}echo "</ul>";}?> Posted in Php | Trackback Url








No Responses to “simplexml_load_string() error when loading XML content from Twitter”
Trackbacks/Pingbacks
Leave a reply