Skip to content

Instantly share code, notes, and snippets.

@wboykinm
Created September 20, 2013 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wboykinm/6640439 to your computer and use it in GitHub Desktop.
Save wboykinm/6640439 to your computer and use it in GitHub Desktop.
<?php
$string = <<<XML
<activity>
<title>Test It</title>
<location>
<administrative adm1="South-East" adm2="Administrative unit not available"/>
<coordinates latitude="-24.6545059954867" longitude="25.9085941314697" precision="1"/>
<gazetteer-entry gazetteer-ref="933773">Gaborone</gazetteer-entry>
</location>
</activity>
XML;
$xml = simplexml_load_string($string);
$site = $xml->location;
echo $site->coordinates['latitude'], '<br>', $site->coordinates['longitude'], '<hr>';
echo $site->xpath('../title');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment