I have XML file with this data
<?xml version="1.0" encoding="windows-1251" ?>
<ValCurs Date="06/06/2012" name="Курби асъор">
<Valute ID="036">
<CharCode>AUD</CharCode>
<Nominal>1</Nominal>
<Name>Доллари Австралия</Name>
<Value>4,6430</Value>
</Valute>
<Valute ID="944">
<CharCode>AZN</CharCode>
<Nominal>1</Nominal>
<Name>Манати Озарбойҷон</Name>
<Value>6,0677</Value>
</Valute>
<Valute ID="826">
<CharCode>GBP</CharCode>
<Nominal>1</Nominal>
<Name>Фунт-стерлинги Ингилистон</Name>
<Value>7,3156</Value>
</Valute>
...
and other
How can one get data from the Nominal
and Value
nodes by when Valute
's attribute ID
equals 826
?
You can read XML simply by casting a string to [xml]
:
$xml = [xml](Get-Content foo.xml)
Then you can use
$xml.ValCurs.Valute | Where-Object {$_.ID -eq 826} | Select-Object Nominal,Value
or shorter:
$xml.ValCurs.Valute | ? {$_.ID -eq 826} | select Nominal,Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With