Sum value of XML attributes using PowerShell 2.0

Posted by Yooakim on Stack Overflow See other posts from Stack Overflow or by Yooakim
Published on 2010-06-08T05:11:02Z Indexed on 2010/06/08 5:22 UTC
Read the original article Hit count: 290

Filed under:
|

I have a directory with XML files. I quickly want to go through them and sum upp the value stored in one attribute. I have figured out how to fidn the nodes I am interested in.

For example:

(Select-Xml -Path .\*.xml -XPath "//*[@Attribue = 'valueImlookingfor']").Count

This command gives me the count of elements in all of the XML files in the current directory which has the value "valueImlookingfor" in the "Attribue".

I want to sum up all the values of the "Attribute", not count them. What would be the best way to do this in PowerShell? I am new to PowerShell so this may be trivial but un-known to me...

All tips are much appreciated :-)

© Stack Overflow or respective owner

Related posts about Xml

Related posts about powershell-v2.0