Created
May 11, 2013 11:17
-
-
Save jtuttas/5559681 to your computer and use it in GitHub Desktop.
Zeugnisnoten Durchschnitt
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
cls | |
[xml]$a = Get-Content ("schulklasse_zeugnis.xml") | |
$n = $a.SelectNodes("//pupil") | |
foreach ($p in $n) { | |
$sum=0 | |
$z=$p.zeugnis.FirstChild | |
do { | |
if ($z.Name -ne "fehlzeiten") { | |
$sum=$sum+$z.InnerText | |
} | |
} | |
while ($z=$z.NextSibling) | |
$p.zeugnis.SetAttribute("average",$sum/4) | |
} | |
$a.Save("schulklasse_zeugnis_neu.xml") |
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
<klasse> | |
<pupil name="Andreas" gender="male" age="22"> | |
<zeugnis> | |
<fehlzeiten> | |
<gesamt>8</gesamt> | |
<entschuldigt>7</entschuldigt> | |
</fehlzeiten> | |
<lf1>2</lf1> | |
<lf2>3</lf2> | |
<lf3>2</lf3> | |
<lf4>1</lf4> | |
</zeugnis> | |
</pupil> | |
<pupil name="Nina" gender="female" age="20"> | |
<zeugnis> | |
<fehlzeiten> | |
<gesamt>1</gesamt> | |
<entschuldigt>1</entschuldigt> | |
</fehlzeiten> | |
<lf1>1</lf1> | |
<lf2>2</lf2> | |
<lf3>1</lf3> | |
<lf4>2</lf4> | |
</zeugnis> | |
</pupil> | |
</klasse> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment