Hi Dave,
I had a go trying to pull team stats. I know I’m doing something wrong but don’t know where to start.
Any help is appreciated. Thanks
Maxime
Jake
Andy
Ranko
Javain
Russell
Janio
Leonard
Cristián Andrés
Brian
Deiber Jair
Michael
Bruno Miguel
Ryan
Kamron
Thomas
Florian
Patrick
Ryan
Tosaint
1
3
6
5
2
8
4
7
11
9
10
6nmcuw8asxh6k3l5khx5atmfp
5hxlj4ash5nuwnt40mf5af46h
5r72qv2gbsyevp837ztsye28l
3mdm2bd45bybp9zbt6aspgq21
2fyga1shd4mwcn90mze2pe4tl
cibach2kp6y1w697co2e4k2c5
vw73lu7w6gr72789vp49zmc5
bhkecr2u6neb933eo468i82ui
3oj41up7cc77o5qj3i65szemt
f5i3q488txatpqe9tvmc0838q
dp3chasr11o48ehnokswl8l7u
2jwbnsl7zicnbgutmpop29d61
3f2otwd2ozwk89319ssh9yjmd
emzg4nwcze4zv4f4sh9t7bdn9
4oz12ku4mdjsq7y4sgogpwg2y
84gabnykc01v70413vehqyvah
69chuz7we7jlx255o0ym0m0np
bww0h67l7g6o9syrkp12s7pih
bialn02i06gihzao8dsjvmc8a
68oxh92004pbiboo5b5bf4pg5
Crépeau
Nerwinski
Rose
Veselinović
Brown
Teibert
Bikel Figueiredo Silva
Owusu
Dájome Arboleda
White
Caicedo Mideros
Baldisimo
Boialvo Gaspar
Gauld
Habibullah
Hasal
Jungwirth
Metcalfe
Raposo
Ricketts
M. Crépeau
J. Nerwinski
A. Rose
R. Veselinović
J. Brown
R. Teibert
Janio Bikel
L. Owusu
C. Dájome
B. White
D. Caicedo
M. Baldisimo
Bruno Gaspar
R. Gauld
K. Habibullah
T. Hasal
F. Jungwirth
P. Metcalfe
R. Raposo
T. Ricketts
Centre
Left
Left/Centre
Centre/Right
Right
Left/Centre
Centre
Centre/Right
Left/Centre
Centre
Centre/Right
Goalkeeper
Defender
Defender
Defender
Defender
Midfielder
Midfielder
Midfielder
Striker
Striker
Striker
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Brad
Nick
Matt
Jhohan Sebastián
Hector Osvaldo
Alexander
Daniel
Tomás
Cecilio Andrés
Diego Santiago
Sebastián
Sebastian
Julio César
Jon
Frederik
Žan
Jared
Rodney Iván
Aedan
Andrew
1
3
6
5
2
4
8
11
10
7
9
5ym1q9duaf8gaumjc83ze4vyt
8mjjt1miy57nwm5iy8usck4q1
3zvj76iwkxqp853t8sjt58t1
2v9a6ag22zeaezp0t32mo6i21
crlprp30citeo87zkm7juxlg5
5j2hy92q8f17nppznxrp8kxxx
cz3k865qdwn8apn8e6xa2lu6s
81hv42gi3qhbs00zoro50y1nt
cfth80ffvgnveork3pqd14atx
ca82vaxv1vz6x0dye3gafzjkl
bovgpaqiyr161smsebisx3o5
54b4j04ondrq28e4eenma1rai
4d6cfs28p6vb6q1ijkw3dks7p
ecp53k8d0t7yczah3aebn0yne
b7hyxpaqt3ymfbuah1yop5rai
ev5e7r7m60jqpvaxigduuwa1
23pxtcocf0xyxeh31ac3hxgx5
dp79admqqqmme9e6l9bhu41gq
637c2iedo7modc3ekt36c2m7d
1e8v2xaqa6v181ryoqids2zmx
Stuver
Lima
Besler
Romaña Espitia
Jimenez
Ring
Pereira Gil
Pochettino
Domínguez Ruiz
Fagúndez Pepe
Driussi
Berhalter
Cascante Solórzano
Gallagher
Kleemann
Kolmanič
Presson Stroud
Redes Cáceres
Stanley
Tarbell
B. Stuver
N. Lima
M. Besler
J. Romaña
H. Jimenez
A. Ring
Daniel Pereira
T. Pochettino
C. Domínguez
D. Fagúndez
S. Driussi
S. Berhalter
J. Cascante
J. Gallagher
F. Kleemann
Ž. Kolmanič
Jared Stroud
R. Redes
A. Stanley
A. Tarbell
Centre
Left
Left/Centre
Centre/Right
Right
Left/Centre
Centre/Right
Left
Centre
Right
Centre
Goalkeeper
Defender
Defender
Defender
Defender
Defensive Midfielder
Defensive Midfielder
Attacking Midfielder
Attacking Midfielder
Attacking Midfielder
Striker
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
Substitute
ap_full_name
ap_first_name
ap_last_name
ap_match_name
ap_position
ap_shirt_num
ap_formation
hp_full_name
hp_first_name
hp_last_name
hp_match_name
hp_position
hp_shirt_num
hp_formation
Maxime Crépeau
Jake Nerwinski
Andy Rose
Ranko Veselinović
Javain Brown
Russell Teibert
Janio Bikel Figueiredo Silva
Leonard Owusu
Cristián Andrés Dájome Arboleda
Brian White
Deiber Jair Caicedo Mideros
Michael Baldisimo
Bruno Miguel Boialvo Gaspar
Ryan Gauld
Kamron Habibullah
Thomas Hasal
Florian Jungwirth
Patrick Metcalfe
Ryan Raposo
Tosaint Ricketts
Brad Stuver
Nick Lima
Matt Besler
Jhohan Sebastián Romaña Espitia
Hector Osvaldo Jimenez
Alexander Ring
Daniel Pereira Gil
Tomás Pochettino
Cecilio Andrés Domínguez Ruiz
Diego Santiago Fagúndez Pepe
Sebastián Driussi
Sebastian Berhalter
Julio César Cascante Solórzano
Jon Gallagher
Frederik Kleemann
Žan Kolmanič
Jared Presson Stroud
Rodney Iván Redes Cáceres
Aedan Stanley
Andrew Tarbell
duy1fgi7q8wkysvm6v6kejld5
di08wknq61nq7rt4oct7i8ted
1ig2npfzwpgm8yro3o104a9xx
4irk92ip7udts4b79eh4v602d
Mendoza
Garner
McKay
Penso
Rosendo
Adam
Ian
Tori
Main
Lineman 1
Lineman 2
Fourth official
mo_full_name
mo_first_name
mo_last_name
mo_type
mo_id
function getPlayerInfo(XMLDoc, contestant_id, team){
//Extracts player info from source
var players_path = '/matchStats/liveData/lineUp[@contestantId="'+contestant_id+'"]/player'
var players = ogscript.runXPath(players_path, XMLDoc);
for (var i = 0; i < players.length; i++) {
var node = players.item(i);
var playerId = node.getAttribute('playerId');
var formationPlace = node.getAttribute('formationPlace');
var positionSide = node.getAttribute('positionSide');
var shirtNumber = node.getAttribute('shirtNumber');
var matchName = node.getAttribute('matchName');
var lastName = node.getAttribute('lastName');
var firstName = node.getAttribute('firstName');
var position = node.getAttribute('position');
if (team=="away"){
params.setValue("ap_id", i, playerId);
params.setValue("ap_formation", i, formationPlace);
params.setValue("ap_position_side", i, positionSide);
params.setValue("ap_shirt_num", i, shirtNumber);
params.setValue("ap_match_name", i, matchName);
params.setValue("ap_last_name", i, lastName);
params.setValue("ap_first_name", i, firstName);
params.setValue("ap_position", i, position);
params.setValue("ap_full_name", i, firstName+" "+lastName);
}
else if (team=="home"){
params.setValue("hp_id", i, playerId);
params.setValue("hp_formation", i, formationPlace);
params.setValue("hp_position_side", i, positionSide);
params.setValue("hp_shirt_num", i, shirtNumber);
params.setValue("hp_match_name", i, matchName);
params.setValue("hp_last_name", i, lastName);
params.setValue("hp_first_name", i, firstName);
params.setValue("hp_position", i, position);
params.setValue("hp_full_name", i, firstName+" "+lastName);
}
}
}
function getTeamInfo(XMLDoc){
//Extracts team info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo/contestants/contestant’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var name = node.getAttribute(‘name’);
var id = node.getAttribute(‘id’);
var position = node.getAttribute(‘position’);
var code = node.getAttribute(‘code’);
var officialName = node.getAttribute(‘officialName’);
var shortName = node.getAttribute(‘shortName’);
if (position=="away"){
params.setValue("a_id", 0, id);
params.setValue("a_name", 0, name);
params.setValue("a_code", 0, code);
params.setValue("a_official_name", 0, officialName);
params.setValue("a_short_name", 0, shortName);
}
else if (position=="home"){
params.setValue("h_id", 0, id);
params.setValue("h_name", 0, name);
params.setValue("h_code", 0, code);
params.setValue("h_official_name", 0, officialName);
params.setValue("h_short_name", 0, shortName);
}
}
}
function getteamOfficialInfo(XMLDoc, contestant_id, team){
//Extracts teamOfficial info from source
var teamOfficial_path = ‘/matchStats/liveData/lineUp[@contestantId="’+contestant_id+‘"]/teamOfficial’
var teamOfficial = ogscript.runXPath(teamOfficial_path, XMLDoc);
for (var i = 0; i < teamOfficial.length; i++) {
var node = teamOfficial.item(i);
var id = node.getAttribute(‘id’);
var lastName = node.getAttribute(‘lastName’);
var firstName = node.getAttribute(‘firstName’);
var type = node.getAttribute(‘type’);
if (team=="away"){
params.setValue("am_id", i, id);
params.setValue("am_last_name", i, lastName);
params.setValue("am_first_name", i, firstName);
params.setValue("am_type", i, type);
params.setValue("am_full_name", i, firstName+" "+lastName);
}
else if (team=="home"){
params.setValue("hm_id", i, id);
params.setValue("hm_last_name", i, lastName);
params.setValue("hm_first_name", i, firstName);
params.setValue("hm_type", i, type);
params.setValue("hm_full_name", i, firstName+" "+lastName);
}
}
}
function getMatchOfficialInfo(XMLDoc){
//Extracts match official info from source
var found = ogscript.runXPath(‘/matchStats/liveData/matchDetailsExtra/matchOfficials/matchOfficial’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var id = node.getAttribute(‘id’);
var firstName = node.getAttribute(‘firstName’);
var lastName = node.getAttribute(‘lastName’);
var type = node.getAttribute(‘type’);
params.setValue("mo_id", i, id);
params.setValue("mo_first_name", i, firstName);
params.setValue("mo_last_name", i, lastName);
params.setValue("mo_type", i, type);
params.setValue("mo_full_name", i, firstName+" "+lastName);
}
}
function getMatchInfo(XMLDoc){
//Extracts match info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var id = node.getAttribute(‘id’);
params.setValue("m_id", i, id);
}
}
function getCompetitionInfo(XMLDoc){
//Extracts competition info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo/competition’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var name = node.getAttribute(‘name’);
params.setValue("m_competition", i, name);
}
}
function getVenueInfo(XMLDoc){
//Extracts venue info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo/venue’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var longName = node.getAttribute(‘longName’);
params.setValue("m_venue", i, longName);
}
}
var XMLDoc = ogscript.parseXML(params.getValue(“rss_feed”, 0));
if (XMLDoc == null) {
ogscript.debug(‘Failed to find source’);
} else {
ogscript.debug(“Found source”);
//Grabbing Team Info
getTeamInfo(XMLDoc);
//Grabbing Player Info
getPlayerInfo(XMLDoc, params.getValue(“h_id”, 0), “home”);
getPlayerInfo(XMLDoc, params.getValue(“a_id”, 0 ), “away”);
//Grabbing teamOfficial Info
getteamOfficialInfo(XMLDoc, params.getValue(“h_id”, 0), “home”);
getteamOfficialInfo(XMLDoc, params.getValue(“a_id”, 0 ), “away”);
//Grabbing matchOfficial Info
getMatchOfficialInfo(XMLDoc);
//Grabbing match Info
getMatchInfo(XMLDoc);
//Grabbing competition Info
getCompetitionInfo(XMLDoc);
//Grabbing venue Info
getVenueInfo(XMLDoc);
}
//Emptying team stats
//Away stats
params.setValue(“a_id”, 0, null);
params.setValue(“a_code”, 0, null);
params.setValue(“a_name”, 0, null);
params.setValue(“a_official_name”, 0, null);
params.setValue(“a_short_name”, 0, null);
params.setValue(“ac_full_name”, 0, null);
params.setValue(“a_logo”, 0, null);
//Home stats
params.setValue(“h_id”, 0, null);
params.setValue(“h_code”, 0, null);
params.setValue(“h_name”, 0, null);
params.setValue(“h_official_name”, 0, null);
params.setValue(“h_short_name”, 0, null);
params.setValue(“hc_full_name”, 0, null);
params.setValue(“h_logo”, 0, null);
//Emptying player stats
var empty = new Array();
//Away stats
params.setAllValues(“ap_id”, empty);
params.setAllValues(“ap_first_name”, empty);
params.setAllValues(“ap_formation”, empty);
params.setAllValues(“ap_last_name”, empty);
params.setAllValues(“ap_match_name”, empty);
params.setAllValues(“ap_position”, empty);
params.setAllValues(“ap_position_side”, empty);
params.setAllValues(“ap_shirt_num”, empty);
params.setAllValues(“ap_full_name”, empty);
params.setAllValues(“ap_custom_text”, empty);
params.setValue(“ap_full_name”, 0, null);
params.setValue(“ap_full_name”, 1, null);
params.setValue(“ap_full_name”, 2, null);
params.setValue(“ap_full_name”, 3, null);
params.setValue(“ap_full_name”, 4, null);
params.setValue(“ap_full_name”, 5, null);
params.setValue(“ap_full_name”, 6, null);
params.setValue(“ap_full_name”, 7, null);
params.setValue(“ap_full_name”, 8, null);
params.setValue(“ap_full_name”, 9, null);
params.setValue(“ap_full_name”, 10, null);
params.setValue(“ap_full_name”, 11, null);
params.setValue(“ap_full_name”, 12, null);
params.setValue(“ap_full_name”, 13, null);
params.setValue(“ap_full_name”, 14, null);
params.setValue(“ap_full_name”, 15, null);
params.setValue(“ap_full_name”, 16, null);
params.setValue(“ap_full_name”, 17, null);
params.setValue(“ap_full_name”, 18, null);
params.setValue(“ap_full_name”, 19, null);
params.setValue(“ap_shirt_num”, 0, null);
params.setValue(“ap_shirt_num”, 1, null);
params.setValue(“ap_shirt_num”, 2, null);
params.setValue(“ap_shirt_num”, 3, null);
params.setValue(“ap_shirt_num”, 4, null);
params.setValue(“ap_shirt_num”, 5, null);
params.setValue(“ap_shirt_num”, 6, null);
params.setValue(“ap_shirt_num”, 7, null);
params.setValue(“ap_shirt_num”, 8, null);
params.setValue(“ap_shirt_num”, 9, null);
params.setValue(“ap_shirt_num”, 10, null);
params.setValue(“ap_shirt_num”, 11, null);
params.setValue(“ap_shirt_num”, 12, null);
params.setValue(“ap_shirt_num”, 13, null);
params.setValue(“ap_shirt_num”, 14, null);
params.setValue(“ap_shirt_num”, 15, null);
params.setValue(“ap_shirt_num”, 16, null);
params.setValue(“ap_shirt_num”, 17, null);
params.setValue(“ap_shirt_num”, 18, null);
params.setValue(“ap_shirt_num”, 19, null);
params.setValue(“ap_custom_text”, 0, null);
params.setValue(“ap_custom_text”, 1, null);
params.setValue(“ap_custom_text”, 2, null);
params.setValue(“ap_custom_text”, 3, null);
params.setValue(“ap_custom_text”, 4, null);
params.setValue(“ap_custom_text”, 5, null);
params.setValue(“ap_custom_text”, 6, null);
params.setValue(“ap_custom_text”, 7, null);
params.setValue(“ap_custom_text”, 8, null);
params.setValue(“ap_custom_text”, 9, null);
params.setValue(“ap_custom_text”, 10, null);
params.setValue(“ap_custom_text”, 11, null);
params.setValue(“ap_custom_text”, 12, null);
params.setValue(“ap_custom_text”, 13, null);
params.setValue(“ap_custom_text”, 14, null);
params.setValue(“ap_custom_text”, 15, null);
params.setValue(“ap_custom_text”, 16, null);
params.setValue(“ap_custom_text”, 17, null);
params.setValue(“ap_custom_text”, 18, null);
params.setValue(“ap_custom_text”, 19, null);
//Home stats
params.setAllValues(“hp_id”, empty);
params.setAllValues(“hp_first_name”, empty);
params.setAllValues(“hp_formation”, empty);
params.setAllValues(“hp_last_name”, empty);
params.setAllValues(“hp_match_name”, empty);
params.setAllValues(“hp_position”, empty);
params.setAllValues(“hp_position_side”, empty);
params.setAllValues(“hp_shirt_num”, empty);
params.setAllValues(“hp_full_name”, empty);
params.setValue(“hp_full_name”, 0, null);
params.setValue(“hp_full_name”, 1, null);
params.setValue(“hp_full_name”, 2, null);
params.setValue(“hp_full_name”, 3, null);
params.setValue(“hp_full_name”, 4, null);
params.setValue(“hp_full_name”, 5, null);
params.setValue(“hp_full_name”, 6, null);
params.setValue(“hp_full_name”, 7, null);
params.setValue(“hp_full_name”, 8, null);
params.setValue(“hp_full_name”, 9, null);
params.setValue(“hp_full_name”, 10, null);
params.setValue(“hp_full_name”, 11, null);
params.setValue(“hp_full_name”, 12, null);
params.setValue(“hp_full_name”, 13, null);
params.setValue(“hp_full_name”, 14, null);
params.setValue(“hp_full_name”, 15, null);
params.setValue(“hp_full_name”, 16, null);
params.setValue(“hp_full_name”, 17, null);
params.setValue(“hp_full_name”, 18, null);
params.setValue(“hp_full_name”, 19, null);
params.setValue(“hp_shirt_num”, 0, null);
params.setValue(“hp_shirt_num”, 1, null);
params.setValue(“hp_shirt_num”, 2, null);
params.setValue(“hp_shirt_num”, 3, null);
params.setValue(“hp_shirt_num”, 4, null);
params.setValue(“hp_shirt_num”, 5, null);
params.setValue(“hp_shirt_num”, 6, null);
params.setValue(“hp_shirt_num”, 7, null);
params.setValue(“hp_shirt_num”, 8, null);
params.setValue(“hp_shirt_num”, 9, null);
params.setValue(“hp_shirt_num”, 10, null);
params.setValue(“hp_shirt_num”, 11, null);
params.setValue(“hp_shirt_num”, 12, null);
params.setValue(“hp_shirt_num”, 13, null);
params.setValue(“hp_shirt_num”, 14, null);
params.setValue(“hp_shirt_num”, 15, null);
params.setValue(“hp_shirt_num”, 16, null);
params.setValue(“hp_shirt_num”, 17, null);
params.setValue(“hp_shirt_num”, 18, null);
params.setValue(“hp_shirt_num”, 19, null);
params.setValue(“hp_custom_text”, 0, null);
params.setValue(“hp_custom_text”, 1, null);
params.setValue(“hp_custom_text”, 2, null);
params.setValue(“hp_custom_text”, 3, null);
params.setValue(“hp_custom_text”, 4, null);
params.setValue(“hp_custom_text”, 5, null);
params.setValue(“hp_custom_text”, 6, null);
params.setValue(“hp_custom_text”, 7, null);
params.setValue(“hp_custom_text”, 8, null);
params.setValue(“hp_custom_text”, 9, null);
params.setValue(“hp_custom_text”, 10, null);
params.setValue(“hp_custom_text”, 11, null);
params.setValue(“hp_custom_text”, 12, null);
params.setValue(“hp_custom_text”, 13, null);
params.setValue(“hp_custom_text”, 14, null);
params.setValue(“hp_custom_text”, 15, null);
params.setValue(“hp_custom_text”, 16, null);
params.setValue(“hp_custom_text”, 17, null);
params.setValue(“hp_custom_text”, 18, null);
params.setValue(“hp_custom_text”, 19, null);
//Emptying teamOfficial stats
var empty = new Array();
//Away stats
params.setAllValues(“am_id”, empty);
params.setAllValues(“am_first_name”, empty);
params.setAllValues(“am_last_name”, empty);
params.setAllValues(“am_type”, empty);
params.setAllValues(“am_full_name”, empty);
params.setValue(“am_full_name”, 0, null);
//Home stats
params.setAllValues(“hm_id”, empty);
params.setAllValues(“hm_first_name”, empty);
params.setAllValues(“hm_last_name”, empty);
params.setAllValues(“hm_type”, empty);
params.setAllValues(“hm_full_name”, empty);
params.setValue(“hm_full_name”, 0, null);
//Emptying official stats
var empty = new Array();
//Official stats
params.setAllValues(“mo_id”, empty);
params.setAllValues(“mo_type”, empty);
params.setAllValues(“mo_first_name”, empty);
params.setAllValues(“mo_last_name”, empty);
params.setAllValues(“mo_full_name”, empty);
params.setValue(“mo_full_name”, 0, null);
params.setValue(“mo_full_name”, 1, null);
params.setValue(“mo_full_name”, 2, null);
params.setValue(“mo_full_name”, 3, null);
params.setValue(“mo_type”, 0, null);
params.setValue(“mo_type”, 1, null);
params.setValue(“mo_type”, 2, null);
params.setValue(“mo_type”, 3, null);
//Emptying match details stats
var empty = new Array();
//Match details stats
params.setValue(“m_id”, 0, null);
params.setValue(“m_competition”, 0, null);
params.setValue(“m_round”, 0, null);
params.setValue(“m_venue”, 0, null);
params.setValue(“m_city”, 0, null);
params.setValue(“m_kickoffTime”, 0, null);
function getPlayerStatsInfo(XMLDoc, contestant_id, team){
//Extracts player stats info from source
var stats_path = ‘/matchStats/liveData/lineUp[@contestantId="’+contestant_id+‘"]/teamStats/stat’
var stats = ogscript.runXPath(stats_path, XMLDoc);
for (var i = 0; i < stats.length; i++) {
var node = stats.item(i);
var totalScoringAtt = node.getAttribute(‘type=(totalScoringAtt)’);
var ontargetScoringAtt = node.getAttribute(‘ontargetScoringAtt’);
var possessionPercentage = node.getAttribute(‘possessionPercentage’);
var wonCorners = node.getAttribute(‘wonCorners’);
var fkFoulLost = node.getAttribute(‘fkFoulLost’);
var totalYellowCard = node.getAttribute(‘totalYellowCard’);
var totalRedCard = node.getAttribute(‘totalRedCard’);
if (team=="away"){
params.setValue("sa_shots", i, totalScoringAtt);
params.setValue("sa_ontarget", i, ontargetScoringAtt);
params.setValue("sa_possession", i, possessionPercentage);
params.setValue("sa_corners", i, wonCorners);
params.setValue("sa_fouls", i, fkFoulLost);
params.setValue("sa_yellowcards", i, totalYellowCard);
params.setValue("sa_redcards", i, totalRedCard);
}
else if (team=="home"){
params.setValue("sh_shots", i, totalScoringAtt);
params.setValue("sh_ontarget", i, ontargetScoringAtt);
params.setValue("sh_possession", i, possessionPercentage);
params.setValue("sh_corners", i, wonCorners);
params.setValue("sh_fouls", i, fkFoulLost);
params.setValue("sh_yellowcards", i, totalYellowCard);
params.setValue("sh_redcards", i, totalRedCard);
}
}
}
function getTeamInfo(XMLDoc){
//Extracts team info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo/contestants/contestant’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var name = node.getAttribute(‘name’);
var id = node.getAttribute(‘id’);
var position = node.getAttribute(‘position’);
var code = node.getAttribute(‘code’);
var officialName = node.getAttribute(‘officialName’);
var shortName = node.getAttribute(‘shortName’);
if (position=="away"){
params.setValue("a_id", 0, id);
params.setValue("a_name", 0, name);
params.setValue("a_code", 0, code);
params.setValue("a_official_name", 0, officialName);
params.setValue("a_short_name", 0, shortName);
}
else if (position=="home"){
params.setValue("h_id", 0, id);
params.setValue("h_name", 0, name);
params.setValue("h_code", 0, code);
params.setValue("h_official_name", 0, officialName);
params.setValue("h_short_name", 0, shortName);
}
}
}
function getMatchInfo(XMLDoc){
//Extracts match info from source
var found = ogscript.runXPath(‘/matchStats/matchInfo’, XMLDoc);
for (var i = 0; i < found.length; i++) {
var node = found.item(i);
var id = node.getAttribute(‘id’);
params.setValue("m_id", i, id);
}
}
var XMLDoc = ogscript.parseXML(params.getValue(“rss_feed”, 0));
if (XMLDoc == null) {
ogscript.debug(‘Failed to find source’);
} else {
ogscript.debug(“Found source”);
//Grabbing Team Info
getTeamInfo(XMLDoc);
//Grabbing PlayerStats Info
getPlayerInfo(XMLDoc, params.getValue(“h_id”, 0), “home”);
getPlayerInfo(XMLDoc, params.getValue(“a_id”, 0 ), “away”);
//Grabbing match Info
getMatchInfo(XMLDoc);
}
//Emptying goal stats
var empty = new Array();
//Goal stats
params.setAllValues(“sa_possession”, empty);
params.setAllValues(“sa_shots”, empty);
params.setAllValues(“sa_ontarget”, empty);
params.setAllValues(“sa_corners”, empty);
params.setAllValues(“sa_fouls”, empty);
params.setAllValues(“sa_yellowcards”, empty);
params.setAllValues(“sa_redcards”, empty);
params.setAllValues(“sh_possession”, empty);
params.setAllValues(“sh_shots”, empty);
params.setAllValues(“sh_ontarget”, empty);
params.setAllValues(“sh_corners”, empty);
params.setAllValues(“sh_fouls”, empty);
params.setAllValues(“sh_yellowcards”, empty);
params.setAllValues(“sh_redcards”, empty);