Reputation: 35684
var xmlData:XML = XML(<data>
<item>
<type atr="a">AAA</type>
<type atr="b">BBB</type>
</item>
<item>
<type atr="c">CCC</type>
</item>
</data>);
trace(xmlData.item.(type=='AAA')); // does not work
trace(xmlData.item.(type=='CCC')); // works
trace(xmlData.item.type.(@atr=='a').parent()); // works
trace(xmlData.item.type.(@atr=='c').parent()); // works
It seems that I cannot get a node based on its value when siblings are present, unless I use attributes.
Is there a way to retrieve item based on the value when there is an unknown amount of elements, without looping manually or using attributes?
Upvotes: 0
Views: 60
Reputation: 35684
I found a way, mostly by randomly trying things...
xmlData.item.type.(child(0)=='BBB').parent();
or
xmlData.item.type.(children()=='BBB').parent();
Upvotes: 1
Reputation: 52133
You could use XMLList/contains:
trace(xmlData.item.(type.contains(<type atr="a">AAA</type>)))
// or
trace(xmlData.item.(type.contains("AAA")))
Upvotes: 0