manhattes Posted February 18, 2016 Share Posted February 18, 2016 I am trying to read an RSS feed and the way my code is written, it is only repeating the first result. the xml looks like this: <?xml version="1.0" encoding="ISO-8859-1" ?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Latest Filings - Thu, 18 Feb 2016 14:52:36 EST</title> <link rel="alternate" href="/cgi-bin/browse-edgar?action=getcurrent"/> <link rel="self" href="/cgi-bin/browse-edgar?action=getcurrent"/> <id>http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent</id> <author><name>Webmaster</name><email>webmaster@sec.gov</email></author> <updated>2016-02-18T14:52:36-05:00</updated> <entry> <title>4 - YABUKI JEFFERY W (0001207371) (Reporting)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/1207371/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> </entry> <entry> <title>4 - FISERV INC (0000798354) (Issuer)</title> <link rel="alternate" type="text/html" href="http://www.sec.gov/Archives/edgar/data/798354/000120919116099734/0001209191-16-099734-index.htm"/> <summary type="html"> <b>Filed:</b> 2016-02-18 <b>AccNo:</b> 0001209191-16-099734 <b>Size:</b> 13 KB </summary> <updated>2016-02-18T14:51:18-05:00</updated> <category scheme="http://www.sec.gov/" label="form type" term="4"/> <id>urn:tag:sec.gov,2008:accession-number=0001209191-16-099734</id> and my code is like this: $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $url = 'http://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent&CIK=&type=4&company=&dateb=&owner=include&start=100&count=20&output=atom'; $xml = file_get_contents($url, false,$context); $xml = simplexml_load_string($xml); print_r($xml); foreach ($xml->entry as $entry){ $FnumI=$xml->entry->title; //$FnumC=$xml->entry->title; $Fdate=$xml->entry->updated; $Flink=$xml->entry->link->attributes()->href; $Form=$xml->entry->category->attributes()->term; echo "<tr>"; echo "<td><p>".$FnumI."</p></td>"; //echo "<td><p>".$FnumC."</p></td>"; echo "<td><p>".$Fdate."</p></td>"; echo "<td><p><a href='".$Flink."'> ". $Flink."</p></td>"; echo "<td><p>".$Form."</p></td>"; echo "</tr>"; } Quote Link to comment Share on other sites More sharing options...
Solution requinix Posted February 18, 2016 Solution Share Posted February 18, 2016 Inside the foreach loop you have to use $entry. $xml->entry-> will only get you stuff from the first . Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.