Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $x = simplexml_load_file("publicResults.xml");
- $d = $x->xpath('//lga[@areaCode=028]//contest[@contestType="councillor"]/districts/district');
- $results = [];
- foreach ($d as $dist) {
- $a = $dist->attributes();
- $seats = (string) $dist->numElectedCandidates;
- $ccount = (string) $dist->candidates->attributes()->count;
- $distname = (string) $a->districtName;
- $rollPct = (string) $a->percentRollCounted;
- $rounds = [];
- print "District $distname\n Last updated at ".$a->lastUpdated."\n";
- print " $ccount nominees running for $seats seats\n";
- print " ($rollPct percent maximum number of possible votes counted)\n";
- foreach ($dist->countRound as $r) {
- $a = $r->attributes();
- $total = $r->totalBallots;
- $formal = $r->totalFormalBallots->count;
- $rname = (string) $a->countName;
- $rounds[$rname] = [];
- print " Count round ".$a->id." is $rname\n $total ballots cast of ($formal were formal)\n";
- foreach ($r->primaryVoteResults->candidate as $c) {
- $count = (int) $c->count;
- $catt = (array) $c->attributes();
- $rounds[$rname][$count] = $catt['@attributes'];
- }
- krsort($rounds[$rname]);
- $ptr = 0;
- foreach ($rounds[$rname] as $c => $att) {
- if ($ptr++ >= $seats) {
- break;
- }
- print " Position $ptr: ".$att['ballotName']." with $c\n";
- }
- // print json_encode($rounds[$rname])."\n";
- }
- $results[$distname]=$rounds;
- }
- exit;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement