0

有谁知道是否有办法在 ActionScript 中检索具有特定 a 属性的 XML 子元素的索引?

说...

foo.child.@attribute //index of

我尝试使用这样的方法:

foo.child.@attribute.childIndex()

但它返回-1

4

1 回答 1

1

使用hasOwnProperty方法对我有用:

foo.child.(hasOwnProperty("@attribute")).childIndex()

但是如果元素 with@attribute不是唯一的,那么正确的代码是:

foo.child.(hasOwnProperty("@attribute"))[0].childIndex()
于 2012-05-11T07:38:58.273 回答