PDA

View Full Version : Xml...



rysolag
November 3rd, 2003, 12:05 AM
Here's my script:

xmlTracks = new XML();
xmlTracks.load("myXML.xml");

xmlTracks.onLoad = tracksLoad;

function tracksLoad(success)
{
if(success)
{
for(var i = 0; i < this.childNodes.length; i++)
{
trace(this.childNodes[i].nodeName);
}
trace(this.status);
}
else
{
trace("error");
}
}

Here's the output:

tracks
null
0

and here's the XML:

<tracks>
<song1 name="one"/>
<song2 name="two"/>
<song3 name="three"/>
</tracks>


why does it print the null?

kode
November 3rd, 2003, 12:19 AM
Set its ignoreWhite property to true. :P

http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary840.html

rysolag
November 3rd, 2003, 12:26 AM
xmlTracks.load("myXML.xml");

xmlTracks.onLoad = tracksLoad;

function tracksLoad(success)
{
if(success)
{
this.ignoreWhite = true;
for(var i = 0; i < this.childNodes.length; i++)
{
trace(this.childNodes[i].nodeName);
}
trace(this.status);
}
else
{
trace("error");
}
}

same thing...

kode
November 3rd, 2003, 12:28 AM
... Set it before the XML file is loaded. :sigh:

xmlTracks = new XML();
xmlTracks.ignoreWhite = true;
xmlTracks.onLoad = tracksLoad;
xmlTracks.load("myXML.xml");

rysolag
November 3rd, 2003, 12:31 AM
oops, thanks for the help.

kode
November 3rd, 2003, 12:31 AM
No problem. :P