- Where Developers Learn, Share, & Build Careers
When I try to parse Google RSS feed, I get a network error: Chrome and Firefox developer 500 internal server error tool. The first part of downloading the RSS feed (with curl) works fine.
I found this example here:
Can someone focus on doing me wrong? Thank you.
& lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Strongly //n" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Untitled document & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;? Php if (function_exists ("curl_init")) {$ ch = curl_init (); //curl_setopt($ch,CURLOPT_URL,'http://www.joevasquez.info/feed/ '); Curl_setopt ($ c, CURLOPT_URL, 'http://news.google.com/news?hl=en&topic=t&output=rss'); Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt ($ ch, CURLOPT_HEADER, 0); $ Data = curl_exec ($ ch); Curl_close ($ ch); // print ($ data); $ Doc = new SimpleXmlElement ($ data, LIBXML_NOCDATA); If (isset ($ doc- & gt; channel)) parseRSS ($ doc); Function parseRSS ($ xml) {$ cnt = count ($ xml-> Channel-> item); ($ Url = $ xml-> Channel- & gt; Items [$ i] - & gt; Link; $ Title = ($ I = 0; $ i & lt; $ cnt; $ i ++) $ XML- & gt; Channels & gt; Items [$ i] - & gt; Title; $ Desc = $ XML- & gt; Channel & gt; Items [$ i] - & gt; Description; Echo '& Lt; a href = "'. $ Url. '' & Gt; '. $ Title.' & Lt; / a & gt; '. $ Desc.' & Lt; br & gt; ';}}? & Gt; & lt; / body & gt; & lt; / html & gt;
< P> You forgot to close the bracket after the loop. For ($ i = 0; $ i Items [$ i] - & gt; Link; $ Title = $ XML- & gt; Channels & gt; Items [$ i] - & gt; Title; $ Desc = $ XML- & gt; Channels & gt; Items [$ i] - & Gt; description;}
Comments
Post a Comment