1

I use this code in as3 in order to find node with specific id value but it is working for 2 depth

elementsToDraw = elementsList.*.(@id=="hello");

For example at this xml node can be found

<nodes>
 <node id="d">
  <node id="hello">
  </node>
 </node>
</nodes>

but this code get no results at

<nodes>
 <node id="d">
  <node id="d1">
   <node id="hello">
   </node>
  </node>
 </node>
</nodes>

What should I write for searching in any depth element with id="hello"?

1
  • 1
    How about writing a recursive function that looks for attributes in descendants too ? Commented Nov 10, 2011 at 21:33

1 Answer 1

3

Why not use .. notation to search for all node :

var elementsList:XML=<nodes>
 <node id="d">
   <node id="hello"/>
   <node id="d1">
   <node id="hello">
   </node>
  </node>
 </node>
</nodes>;

var xl:XMLList=elementsList..*.(@id=="hello");

trace(xl.toXMLString());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.