Flex XML问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 22:40:54
xml对象如下
<folder state="schrodinger" label="公司" isBranch="true">
<folder state="schrodinger" isBranch="true" label="物流事业部">
<folder state="unchecked" isBranch="false" label="wl1"/>
<folder state="unchecked" isBranch="false" label="wl2"/>
<folder state="unchecked" isBranch="false" label="wl3"/>
<folder state="unchecked" isBranch="false" label="wl4"/>
<folder state="unchecked" isBranch="false" label="wl5"/>
<folder state="unchecked" isBranch="false" label="wl6"/>
<folder state="unchecked" isBranch="false" label="wl7"/>
<folder state="checked" isBranch="false" label=

用xml..folder.(@state=="checked" && @isBranch=="false")这句来查询看看。
..表示匹配里面所有的folder节点。

xml..folder.(@state=="checked" && @isBranch=="false")返回的是XMLList对象的,所以可以这样:
var tmp:XMLList=xml..folder.(@state=="checked" && @isBranch=="false");
var str:String="";
for(var i:int=0;i<tmp.length();i++){
if(str==""){
str=tmp[i].@label;
}else{
str+=","+tmp[i].@label;
}
}