Created
May 13, 2013 13:10
-
-
Save jtuttas/5568211 to your computer and use it in GitHub Desktop.
Nebenkosten berechnen wie in IHK Prüfung 2012
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[xml] $xml = gc "Nebenkosten.xml" | |
[float]$sum=0; | |
foreach($node in $xml.GetElementsByTagName("Haus")) | |
{ | |
$max=$node.childnodes.count | |
$item=$node.FirstChild | |
for ($i=0;$i -lt $max;$i++) { | |
$sum+=[float]$item.InnerText | |
$item=$item.NextSibling | |
} | |
} | |
echo ("Die gesamten Nebenkosten betragen: "+$sum+" EUR") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Nebenkosten> | |
<Haus ID="1234"> | |
<Muell>1200</Muell> | |
<Wasser>3000</Wasser> | |
<Strom>500</Strom> | |
<Versicherungen>2400</Versicherungen> | |
</Haus> | |
<Haus ID="4321"> | |
<Muell>3800</Muell> | |
<Wasser>8900</Wasser> | |
<Strom>1200</Strom> | |
<Versicherungen>7800</Versicherungen> | |
</Haus> | |
</Nebenkosten> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment