Jump to content

Recommended Posts

I am using a feed (http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M5.xml) with the google maps API to try and make a map with markers of all earthquakes in the last 7 days.

 

I am trying to get simplexml_load_file to recognize the geo namespace but there's no documentation on it. 

There is no documentation with the ns parameter of that function and I am currently trying to deal with namespaces in an XML feed.

Hi there, if you would click on the "Report a bug" link on that page and fill out a documentation bug report then the documentation team will be made aware of the omission.  If you could do that, it would be great.

 

I am using a feed (http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M5.xml) with the google maps API to try and make a map with markers of all earthquakes in the last 7 days.

 

I am trying to get simplexml_load_file to recognize the geo namespace but there's no documentation on it. 

By default, simplexml_load_file creates (a heirarchy of) SimpleXMLElement objects and you can use the SimpelXMLElement::children method to access namespaced child nodes. A quick example would be:

 

$xml = simplexml_load_file('http://earthquake.usgs.gov/eqcenter/catalogs/eqs7day-M5.xml');
foreach ($xml->channel->item as $item) {
    $geo = $item->children('geo', TRUE);
    echo "At " . $geo->lat . "," . $geo->long . " was " . $item->title . ".\n";
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.