Jump to content

Lack of simpleXML Documentation


jrw4

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";
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.