Xpath search example

$ecbRates = simplexml_load_file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
$namespaces = $ecbRates->getDocNamespaces();
$ecbRates->registerXPathNamespace("ecb", $namespaces['']);
$array = $ecbRates->xpath("//ecb:Cube[@currency='GBP']/@rate");
echo (string) $array[0]['rate'];

Leave a Reply