Faust
07-08-2004, 09:01 PM
okay i know i am asking for help that has been thrown around alot on this forum and i have probably read more then 75% of them in the past 2 days and yet i can't find anything that really solves the problem:
XML FILE:
<?xml version="1.0" encoding="utf-8" ?>
<xmlsonglist>
<totalSongs number="3" />
<song>
<Title>Bartender</Title>
<Artist>Rehab</Artist>
<Album>N/A</Album>
<Genre>Rock</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/bartender.mp3</Path>
</song>
<song>
<Title>Daffy Duck</Title>
<Artist>N/A</Artist>
<Album>N/A</Album>
<Genre>Comedy</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/dd.mp3</Path>
</song>
<song>
<Title>Souther Hospitality</Title>
<Artist>Ludicris</Artist>
<Album>Chicken&Beer</Album>
<Genre>Rap</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/southern_hosp.mp3</Path>
</song>
</xmlsonglist>
XML LOAD AND PARSER
PLXML = new XML();
PLXML.ignoreWhite = true;
PLXML.load("http://studentwebs.colstate.edu/huot_justin/Mp3_Player/Faust.xml");
PLXML.onLoad = xmlLoaded;
function xmlLoaded(success) {
if (success) {
trace("XML file is loaded");
parseXML();
} else {
trace("*** XML FILE DID NOT LOAD ***");
}
}
// makes Arrays
aryItem = new Array("Title", "Artist", "Album", "Genre", "Path");
aryTitle = new Array();
aryArtist = new Array();
aryAlbum = new Array();
aryGenre = new Array();
aryPath = new Array();
// Parse the XML
function parseXML() {
totalSongs = PLXML.firstChild.firstChild.attributes.number;
//trace("Number of songs: " + totalSongs);
for (n=0; n<PLXML.firstChild.childNodes.length; n++) {
//trace(PLXML.firstChild.childNodes.length);
if (PLXML.firstChild.childNodes[n].nodeName == "song") {
//trace(PLXML.firstChild.childNodes[n].nodeName);
for (i=0; i<PLXML.firstChild.childNodes[n].childNodes.length; i++) {
//trace(PLXML.firstChild.childNodes[n].childNodes[i].firstChild.nodeValue);
if (PLXML.firstChild.childNodes[n].childNodes[i].nodeName == aryItem[i]) {
this["ary"+aryItem[i]].push(PLXML.firstChild.childNodes[n].childNodes[i].firstChild.nodeValue);
}
}
}
}
populateListBox();
}
function populateListBox() {
trace("Funciton PopulateListBox running...");
for (j=0; j<aryArtist.length; j++) {
trace(aryArtist[j].toString());
file = aryArtist[j]+" : "+aryTitle[j];
trace(file.toString());
//Listbox is lstPlayList1
_root.lstPlayList1.addItem(file, aryPath[j].toString());
}
trace("... PopulateListBox is Closing");
}
the majority of the parser came from a post on here and that works great. as you can see in the output:
XML file is loaded
Funciton PopulateListBox running...
Rehab
Rehab : Bartender
N/A
N/A : Daffy Duck
Ludicris
Ludicris : Souther Hospitality
... PopulateListBox is Closing
so if this is in the array why won't it populate the listbox???
for (j=0; j<aryArtist.length; j++) {
trace(aryArtist[j].toString());
file = aryArtist[j]+" : "+aryTitle[j];
trace(file.toString());
_root.lstPlayList1.addItem(file, aryPath[j].toString());
}
yet when the movie runs nothing is in the Listbox, so i guess my question is if the data in the array is outputed then why won't it add the data to the listbox?
Thanks in advance, :D
Faust
XML FILE:
<?xml version="1.0" encoding="utf-8" ?>
<xmlsonglist>
<totalSongs number="3" />
<song>
<Title>Bartender</Title>
<Artist>Rehab</Artist>
<Album>N/A</Album>
<Genre>Rock</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/bartender.mp3</Path>
</song>
<song>
<Title>Daffy Duck</Title>
<Artist>N/A</Artist>
<Album>N/A</Album>
<Genre>Comedy</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/dd.mp3</Path>
</song>
<song>
<Title>Souther Hospitality</Title>
<Artist>Ludicris</Artist>
<Album>Chicken&Beer</Album>
<Genre>Rap</Genre>
<Path>Http://studentwebs.colstate.edu/huot_justin/sound/southern_hosp.mp3</Path>
</song>
</xmlsonglist>
XML LOAD AND PARSER
PLXML = new XML();
PLXML.ignoreWhite = true;
PLXML.load("http://studentwebs.colstate.edu/huot_justin/Mp3_Player/Faust.xml");
PLXML.onLoad = xmlLoaded;
function xmlLoaded(success) {
if (success) {
trace("XML file is loaded");
parseXML();
} else {
trace("*** XML FILE DID NOT LOAD ***");
}
}
// makes Arrays
aryItem = new Array("Title", "Artist", "Album", "Genre", "Path");
aryTitle = new Array();
aryArtist = new Array();
aryAlbum = new Array();
aryGenre = new Array();
aryPath = new Array();
// Parse the XML
function parseXML() {
totalSongs = PLXML.firstChild.firstChild.attributes.number;
//trace("Number of songs: " + totalSongs);
for (n=0; n<PLXML.firstChild.childNodes.length; n++) {
//trace(PLXML.firstChild.childNodes.length);
if (PLXML.firstChild.childNodes[n].nodeName == "song") {
//trace(PLXML.firstChild.childNodes[n].nodeName);
for (i=0; i<PLXML.firstChild.childNodes[n].childNodes.length; i++) {
//trace(PLXML.firstChild.childNodes[n].childNodes[i].firstChild.nodeValue);
if (PLXML.firstChild.childNodes[n].childNodes[i].nodeName == aryItem[i]) {
this["ary"+aryItem[i]].push(PLXML.firstChild.childNodes[n].childNodes[i].firstChild.nodeValue);
}
}
}
}
populateListBox();
}
function populateListBox() {
trace("Funciton PopulateListBox running...");
for (j=0; j<aryArtist.length; j++) {
trace(aryArtist[j].toString());
file = aryArtist[j]+" : "+aryTitle[j];
trace(file.toString());
//Listbox is lstPlayList1
_root.lstPlayList1.addItem(file, aryPath[j].toString());
}
trace("... PopulateListBox is Closing");
}
the majority of the parser came from a post on here and that works great. as you can see in the output:
XML file is loaded
Funciton PopulateListBox running...
Rehab
Rehab : Bartender
N/A
N/A : Daffy Duck
Ludicris
Ludicris : Souther Hospitality
... PopulateListBox is Closing
so if this is in the array why won't it populate the listbox???
for (j=0; j<aryArtist.length; j++) {
trace(aryArtist[j].toString());
file = aryArtist[j]+" : "+aryTitle[j];
trace(file.toString());
_root.lstPlayList1.addItem(file, aryPath[j].toString());
}
yet when the movie runs nothing is in the Listbox, so i guess my question is if the data in the array is outputed then why won't it add the data to the listbox?
Thanks in advance, :D
Faust