PDA

Просмотр полной версии : flash 8 и xml


V0land
21.09.2006, 12:10
имеется код:


dataXML = new XML();
dataXML.onLoad = convertXML;
dataXml.ignoreWhite = true;
dataXML.load("members.xml");


function convertXML() {
mainTag = new XML();
elementTag = new XML();
dataList = new Array();
elementList = new Array();
mainTag = this.firstChild;
if (dataXML.loaded) {
if (mainTag.nodeName == "Members") {
dataList = mainTag.childNodes;
for (i=0; i<=dataList.length; i++) {
if (dataList[i].nodeName == "Member") {
elementList = dataList[i].childNodes;
for (j=0; j<=elementList.length; j++) {
elementTag = elementList[j];
elementType = elementTag.nodeName;
if (elementType == "Name") {
Name = elementTag.firstChild.nodeValue;
}
if (elementType == "Section") {
Section = elementTag.firstChild.nodeValue;
}
if (elementType == "DeskLocation") {
DeskLocation = elementTag.firstChild.nodeValue;
}
if (elementType == "Responsibilities") {
Responsibilities = elementTag.firstChild.nodeValue;
}
if (elementType == "PersonalInfo") {
PersonalInfo = elementTag.firstChild.nodeValue;
DataStuff = "<b>Name</b>: "+Name+"<br><br>"+"<b>Section: </b>"+Section+"<br><br>"+"<b>Desk Location: </b>"+DeskLocaation+"<br><br>"+"<b>Responsibilities: </b>"+Responsibilities+"<br><br>"+"<b>Personal Info: </b>"+PersonalInfo+"<br><br>";
//testbox.htmlText = Name+".jpg";
}
if (elementType == "PicPath") {
PicPath = elementTag.firstChild.nodeValue;
}
}

listBox.addItem(Name, DataStuff);
listBox.sortItemsBy("label", "ASC");

}
}
}
}

listBox.setChangeHandler("SelectItem");
}

function SelectItem() {
infobox.text = listBox.getSelectedItem().data;
PicPath= listBox.getSelectedItem().label+".jpg";
PicBox.contentPath = PicPath;
}




проблема в том, чт если в заголовке xml файла стоит
<?xml version="1.0" encoding="utf-8" ?>



то ничего в листбокс не добавляется. если подтереть те две строчки, то все ок.


вопрос - что за фигня? :confused:

Pavlenty111
27.09.2006, 18:23
dataXml.ignoreWhite = true; ---> dataXML.ignoreWhite = true;