Night | Snow

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

News

  • Facebook shares see modest debut

    Facebook shares end a volatile first day of trading at $38.23, barely above the company's initial pricing, having initially jumped more than 10%.

  • Met Police to extract phone data

    Mobile phone data of suspects in police custody is to be extracted and retained, regardless of whether charges are brought, the BBC has learned.

  • Silicon trick for next-gen memory

    Researchers reveal details of a promising way to make a fundamentally different kind of computer memory chip.

Martin Fischer said:

Client and partner of simra.ch

Wir können Simon Schärer als kompetenter und zuverlässiger Programmierer höchst weiterempfehlen. Er ist nicht nur ein guter Programmierer, sondern auch ein ausgezeichneter Designer.
Danke Developer’s Island

Follow us on Twitter

favorite

I get asked a lot - which SDK should we use for web programming? I recommend Netbeans

my toolbar

Simra GameMP3 playersubscribe to RSSMy delicious bookmarksFacebookTwitterE-mail

No Responses to “simplexml_load_string() error when loading XML content from Twitter”

RSS Feed Icon  Subscribe to comments follow-up

Trackbacks/Pingbacks

Leave a reply

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Latest Tweet

loading...