我现在正在处理一个XML列表,它看起来如下:
<feature type="startLocation" value="1" x="15" y="3"/>
<feature type="startLocation" value="1" x="15" y="4"/>
<feature type="startLocation" value="1" x="15" y="5"/>
<feature type="startLocation" value="1" x="15" y="6"/>
<feature type="startLocation" value="1" x="15" y="7"/>
这是解析此xmlList(名为this.DropLocationsXML)的actionsicRpt代码:
public function dropUnit()
{
var numX:int;
var numY:int;
var feature:XMLList;
trace(this.dropLocationsXML);
for(var i:int = 0; i < this.dropLocationsXML.length(); i++)
{
feature = this.dropLocationsXML.child(i);
numX = -16 + (feature.@x)*35;
numY = 4 + (feature.@y)*35;
}
}
现在,当我尝试使用child()函数访问这个xmlList时,最终得到一个空的xmlList。
当我尝试使用这个.DropLocationsXML[1]和valueof()方法时,同样的情况也是如此。
如您所见,我只需要从每个特征标记中提取x和y属性。trace()语句提供上面显示的XML输出。
是否有人知道如何访问XML列表的根节点,以便我可以使用x和y属性?