XML : find XML node based on element value when multiples may be present

  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?

No comments:

Post a Comment