views:

31

answers:

1

Hi all,

Could someone please help me out with this.

I need to find the gml:pos namespace in the xml.

But, very important! - in the $item part off the loop

I really have no clue how to get this done.

The namespace is in another custom namespace according to google-api docs.

$feed = simplexml_load_string($feedXml);
foreach ($feed->entry as $item) {

//do stuff
$i++;
}

EDIT I only found this to work.

$namespace = $feed->getDocNamespaces();
$ns_gml=$item->children($namespace['georss'])->children($namespace['gml']);

thanks in adv, Rich

A: 

You need to register these namespaces:

<?php
  $feed->registerXPathNamespace("georss", "http://www.georss.org/georss");
  $feed->registerXPathNamespace("gml", "http://www.opengis.net/gml");
  // Now you can use gml:* and georss:* in XPath:
  // $feed->xpath('/entry/gml:...');
?>
Harmen
$feed->xpath('/entry/gml:pos');--gives back empty array´s? I have read up about relative paths, so I don´t know why it is not working. Anyway I will go with my own found solution. Thanks anyway.
Richard
@Richard: This is rigth about namespaces handling. Is the `entry` root element under some namespace? Maybe a dafault namespace?
Alejandro