Sum value of XML attributes using PowerShell 2.0
- by Yooakim
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 :-)