Elements from xml identify add and count (javascript/php) -


i pointers me going on this, don't know start, appreciate help. have (or +) xml files in format:

    <?xml version="1.0"?> <standings>   <team rank="1" name="fsdfsdf, fsfsdaf" dci="uniquenumberhere" matchpoints="6" matchresultspwdb="2/2/0/0" opponentmatchwinpercent="50" gameswinpercent="66,6667" opponentsgamewinpercent="50" />   <team rank="2" name="dasdasd, asdasd" dci="uniquenumberhere" matchpoints="6" matchresultspwdb="2/2/0/0" opponentmatchwinpercent="41,5" gameswinpercent="80" opponentsgamewinpercent="36,6667" /> </standings> 

what want is:
(1) extract dci key value, unique integer, , every dci add matchpoints , name.
(2) adding more reports (xml) that, multiples occurrences same dci should appear (and add points , return one).
(3) return xml formated (to later process , add other reports - recursive point 2).
(4) option export in htmlt table, after manage extract values formating output change.

first thought in regular expression extract values arrays , after check keyvalue (dci) , add totals , final array , export there. after google search i've seen javascript , php have functions deal xml, didn't see similar looking for.

some on best line of action or quick example great.

so solved using regular expressions, here's code if interested or want give performance/security updates.

//get strings form post $xmldb = $_post["xmldb"]; $xmlup = $_post["xmlup"]; // regular expression $re = "/<team rank=\"\\d+\" name=\"([a-z, ]+)\" dci=\"([0-9]+)\" matchpoints=\"(\\d+)\" matchresultspwdb=\"([0-9]+)\\//mi";  preg_match_all($re, $xmldb, $matches); preg_match_all($re, $xmlup, $matchesup);  $bd = array(); ($i = 0; $i <=  sizeof($matches[1]) -1;$i++  ) {         //print($i);         $bd[$matches[2][$i]] = array                         (                         $matches[1][$i], //nome                         $matches[3][$i],  // pontos                         $matches[4][$i]  // matches                         )                     ;  } $update = array(); ($i = 0; $i <=  sizeof($matchesup[1]) -1;$i++  ) {         print($i);         $update[$matchesup[2][$i]] = array                         (                         $matchesup[1][$i], //nome                         $matchesup[3][$i],  // pontos                         $matchesup[4][$i]    // matches                         )                     ;  } //update bd new values foreach ($update $key => $val) {     if (array_key_exists($key,$bd)) { $nome = $update[$key][0]; $pontos = $update[$key][1] + $bd[$key][1]; $jogos =  $update[$key][2] + $bd[$key][2]; $bd[$key] = array($nome,$pontos,$jogos); }     else $bd[$key] = $val; } 

still missing sort option (printing easy), need sort 2 parameters, believe figure out.


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -