using preg_match from XML feed

irmamink

New Member
I'm trying to get the hang of preg_match but I'm having trouble selecting what I want with regex.I'm using an XML feed found herehttp://www.ecb.int/stats/eurofxref/eurofxref-daily.xmlI want to find a currency and it's value. It's printing as an array, so I'm confused how to do this. Do I need to loop somehow? Even if I do I still haven't figured out the preg_match part.\[code\]<?$xml = simplexml_load_file('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');//print_r($xml);preg_match('/ USD \= \(([0-9\.\,]+)\)$/',$xml,$match);echo $match[1];echo $match[2];?>\[/code\]Any help would be appreciated!edit - I tried to get the example on PHP's site to work using my link but I got a bunch of errors. Here's what I have\[code\]<?$string = simplexml_load_file('http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');$xml = new SimpleXMLElement($string);$result = $xml->xpath('b/c');while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n";}?>\[/code\]
 
Back
Top