PDA

Volledige versie bekijken : XML data opslaan in vars


FredericCox
%Europe/Berlin %691 %2005, 17:35
Hallo ik laad via een xml alle wedstrijden van een seizoen in.

Ik heb een mc Fixture met daarin 4 mc's Match1 tot Match4 en daarin de tekstvakken(HomeTeam, Score enz...)

Nu wil ik alles in variabelen zetten zodat ik ze naderhand via een functie kan opvragen. in dit geval de functie EnterFixtures. Maar de variabelen die ik in de xml aanmaak bestaan niet :s undefined dus, wat doe ik verkeerd, tracen werkt wel, behalve in de functie)

function getResults(LeagueID) {
trace("getting results for"+LeagueID);
ResultsXML = new XML();
_scope = this;
ResultsXML.ignoreWhite = true;
ResultsXML.onLoad = LoadResults;
trace(LeagueID);
ResultsXML.load(_global.xmlFile+"/xml.php?page=leagueFixtures.asp&outputType=XML&actionType=view&leagueLevelUnitID="+LeagueID);
function LoadResults(success) {
CurrentMatchRound = _global.MatchRound;
var MatchNr = 1;
var MatchRound = 1;
for (i=0; i<57; i++) {
if (MatchNr>4) {
MatchNr = 1;
MatchRound++;
trace("Round "+MatchRound);
trace("--------------------");
trace("");
}
//Voor elke match...
trace(MatchNr+":");
trace(ResultsXML.firstChild.childNodes[(8+i)].childNodes[2].childNodes[1].childNodes+" - "+ResultsXML.firstChild.childNodes[(8+i)].childNodes[3].childNodes[1].childNodes);
_scope.Results["Round"+MatchRound]["Match"+MatchNr].MatchID = ResultsXML.firstChild.childNodes[(8+i)].childNodes[0].childNodes;
_scope.Results["Round"+MatchRound]["Match"+MatchNr].HomeTeam = ResultsXML.firstChild.childNodes[(8+i)].childNodes[2].childNodes[1].childNodes;
scope.Results["Round"+MatchRound]["Match"+MatchNr].AwayTeam = ResultsXML.firstChild.childNodes[(8+i)].childNodes[3].childNodes[1].childNodes;
scope.Results["Round"+MatchRound]["Match"+MatchNr].Round = MatchRound;
scope.Results["Round"+MatchRound]["Match"+MatchNr].Datum = ResultsXML.firstChild.childNodes[(8+i)].childNodes[4].childNodes;
MatchNr++;
}
EnterFixtures(CurrentMatchRound);
function EnterFixtures(CurrentMatchRound) {
trace("Plaatqs fiwturesé");
scope = _root.LeagueShow.LeagueDetails;
trace(scope);
MatchRound = CurrentMatchRound;
trace(MatchRound);
for (i=1; i<5; i++) {
trace("Round = "+scope.Results["Round"+MatchRound]["Match"+i].Round);
scope.Results.Fixture["Match"+i].Round = scope.Results["Round"+MatchRound]["Match"+i].Round;
scope.Results.Fixture["Match"+i].MatchID = scope.Results["Round"+MatchRound]["Match"+i].MatchID;
scope.Results.Fixture["Match"+i].HomeTeam = scope.Results["Round"+MatchRound]["Match"+i].HomeTeam;
scope.Results.Fixture["Match"+i].AwayTeam = scope.Results["Round"+MatchRound]["Match"+i].AwayTeam;
scope.Results.Fixture["Match"+i].Datum = scope.Results["Round"+MatchRound]["Match"+i].Datum;
}
}
}
}

Flasher
%Europe/Berlin %731 %2005, 18:33
eerst gebruik je _scope en daarna scope (zonder "_" )
misschien ligt het daar aan.

FredericCox
%Europe/Berlin %767 %2005, 19:25
eerst gebruik je _scope en daarna scope (zonder "_" )
misschien ligt het daar aan.


nope..

trace(_scope.Results["Round"+MatchRound]["Match"+MatchNr] geeft in de xml undefined aan:s dus hij maakt die variabele precies niet aan:s

Dauntless
%Europe/Berlin %831 %2005, 20:57
//....
function LoadResults(success) {
CurrentMatchRound = _global.MatchRound;
var MatchNr = 1;
var MatchRound = 1;
for (i=0; i<57; i++) {
if (MatchNr>4) {
MatchNr = 1;
MatchRound++;
trace("Round "+MatchRound);
trace("--------------------");
trace("");
}// ...

Je ontvangt die 'success' wel, maar je doet er neits mee... Doe een if(success) om te kijken of je data al wel degelijk goed wordt ingeladen! :)