Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- If you look at the feed from the USGS on Mag 5+ earthquakes over the
- past week at:
- < http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M7.xml >
- You will see these sorts of things in each entry:
- <item>
- <pubDate>Sun, 06 Nov 2011 03:53:10 GMT</pubDate>
- <title>M 5.2, Oklahoma</title>
- <description>November 06, 2011 03:53:10 GMT</description>
- <link>http://earthquake.usgs.gov/earthquakes/recenteqsww/Quakes/usb0006klz.php</link>
- <geo:lat>35.5993</geo:lat>
- <geo:long>-96.7515</geo:long>
- <dc:subject>5</dc:subject>
- <dc:subject>pasthour</dc:subject>
- <dc:subject>5.00 km</dc:subject>
- <guid isPermaLink="false">usb0006klz</guid>
- </item>
- The pubDate, title, description, link and guid tags are all part of
- the RSS standard. The geo: and dc: tags are not, and are specified in
- the opening rss tag:
- <rss version="2.0"
- xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
- xmlns:dc="http://purl.org/dc/elements/1.1/">
- by those xmlns attributes. So, unless you're lucky, almost any canned
- solution for dealing with RSS might not work with any particular feed.
- The best solution I've come up with just using SimpleXML (or one of
- it's derivatives). Here's a quickie I wrote to test out the above
- link:
- $feed_raw = file_get_contents("http://earthquake.usgs.gov/earthquakes/catalogs/eqs1day-M2.5.xml");
- $feed = new SimpleXMLElement($feed_raw);
- $feed->registerXPathNamespace('geo','http://www.w3.org/2003/01/geo/wgs84_pos#');
- $feed->registerXPathNamespace('dc','http://purl.org/dc/elements/1.1/');
- echo "<pre>";
- print_r($feed->getNamespaces(TRUE));
- print_r($feed->getDocNamespaces(TRUE));
- echo "</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement