Getting List of Exchange Rates

by Feb 22, 2011

In a previous tip, you learned how to read current exchange rates from the Internet., you can easily create a comprehensive list of all exchange rates by using a hash table:

$xml = New-Object xml
$xml.Load('http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml')

$allrates = @{}
$xml.Envelope.Cube.Cube.Cube | ForEach-Object {
$currency = $_.currency
$rate = $_.rate
$allrates.$currency = $rate
}
"All exchange rates:"
$allrates
"Specific exchange rate:"
$allrates["IDR"]

Twitter This Tip!
ReTweet this Tip!