19

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>Манати Озарбой&#1207;он</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?

1 Answer 1

47

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.