May I refine your question?
"I have an XML tree. How can I select nodes depending on the value of
subnodes or the value of subnode attributes".
Anyway, you should provide a simple test XML that does not work.
Here my next try. When I understand right then you want to select assets
depending on their number or icon. To make it even more illustrative, I
have nested the asset values within a <data> tag.
private var _assets : XML =
<assets>
<asset>
<data>
<number>1</number>
<item icon="top">TOP</item>
</data>
</asset>
<asset>
<data>
<number>2</number>
<item icon="right">RIGHT</item>
</data>
</asset>
<asset>
<data>
<number>3</number>
<item icon="bottom">BOTTOM</item>
</data>
</asset>
<asset>
<data>
<number>4</number>
<item icon="down">DOWN</item>
</data>
</asset>
</assets>
;
public function XMLTest() {
trace(_assets.*.(data.number == "2"));
trace(_assets.*.(data.*.@icon == "down"));
}
Am 17.02.2011 12:58, schrieb Glen Pike:
Hmm, they just return the <number> node from a matching asset in the
list, but if I do this:
var res : XMLList = _assets.child("number").(text() == prop);
if (0 != res.length()) {
trace(this, "getAssetDetails " + res[0].parent().childIndex());
return res[0].parent();
}
I still have the same problem even using the parent???
On 17/02/2011 11:24, Jens Struwe wrote:
Try:
var res : XMLList = _assets.child("number").(text() == prop);
var res:XMLList = _assets.*.(attribute("icon") == String(prop));
Jens
Am 17.02.2011 11:08, schrieb Glen Pike:
Hi,
I am having a problem with getting the childIndex value from an e4x
result:
Both these functions work - e.g. they return an XML node from a list,
but the childIndex property always traces as -1 for the first function.
Can anyone see what the problem is?
TIA
Glen
public function getAssetDetails(prop:*):XML {
if (!_assets) {
return null;
}
var res:XMLList = _assets.(child("number") == String(prop));
if (0 != res.length()) {
debug(this, "getAssetDetails " + res[0].childIndex());
return res[0];
} else {
return null;
}
}
override public function getAssetDetails(prop:*):XML {
if (!_assets) {
return null;
}
var res:XMLList = _assets.(attribute("icon") == String(prop));
if (0 != res.length()) {
debug(this, "getAssetDetails " + res[0].childIndex());
return res[0];
} else {
return null;
}
}
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders