这是我的XML,包含所有图像。我希望得到subategory,sub1,sub2,sub3等的childNodes ......
< allImages>
<images>
<category>Architecture</category>
<img>Arch_1.jpg</img>
<subcategory>
<sub>sub1</sub>
<sub>sub2</sub>
<sub>sub3</sub>
</subcategory>
</images>
<images>
<category>People</category>
<img>People_1.jpg</img>
<subcategory>
<sub>sub4</sub>
<sub>sub5</sub>
</subcategory>
</images>
&LT; / allImages&GT;
以下是AS2代码
function loadXML(loaded){
if(loaded){
xmlNode = this.firstChild;
画廊= [[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]], [[],[],[]]];
category = [];
total = xmlNode.childNodes.length;
for(i = 0; i&lt; total; i ++){
category [i] = xmlNode.childNodes [i] .childNodes [0] .firstChild.nodeValue;
galleries = xmlNode.childNodes [i] .childNodes [1] .childNodes;
迹(类别[I]);
迹(画廊);
}
} 别的{
trace(“xml未加载!”);
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load( “gallery.xml”);
结果如下所示
架构
&LT;子&GT; SUB1&LT; /子&GT;
&LT;子&GT; SUB2&LT; /子&GT;
&LT;子&GT; SUB3&LT; /子&GT;
人
&LT;子&GT; SUB4&LT; /子&GT;
&LT;子&GT; SUB5&LT; /子&GT;
答案 0 :(得分:0)
为了你自己和上帝使用greensock xmlparser