Bart van Heukelom
Bart van Heukelom

Reputation: 44114

Select element containing other element with attribute value in E4X

<root>
 <function name="lala">
  <metadata name="foo" />
 </function>
 <function />
 ...
</root>

In the XML tree above, how can I select the one (or first) function containing a metadata with @name being "foo" in an ActionScript 3 E4X expression?

What I've tried, but doesn't work, is:

// should trace "lala", traces "" 
trace(root.function.(contains(metadata.(@name=="foo"))).@name);

Upvotes: 0

Views: 552

Answers (1)

Bart van Heukelom
Bart van Heukelom

Reputation: 44114

This works, but it's a bit ugly

trace(XML(root.function.metadata.(@name=="foo")).parent().@name);

Upvotes: 1

Related Questions