I have an xml document like the below one that I am trying to parse using AS3. I want to get all of the classes who have students playing Basketball. I thought that I could do something like:
var sport:String = "BasketBall";
var bbClasses:XMLList = xml.classes.class.(students.student.commitments.comm==sport);
Unfortionatly this is returning me an empty XMLList.
<master>
<classes>
<class>
<classID>1</classID>
<teacherID>66</teacherID>
<students>
<student>
<studentID>1</studentID>
<studentDescription>bla bla</studentDescription>
<commitments>
<comm>Hockey</comm>
<comm>Dance</comm>
&l开发者_JAVA百科t;comm>Basketball</comm>
</commitments>
</student>
<student>
<studentID></studentID>
<studentDescription>bla bla</studentDescription>
<commitments>
<comm>Hockey</comm>
<comm>Football</comm>
<comm>Basketball</comm>
</commitments>
</student>
<student>
...
</student>
<student>
...
</student>
</students>
</class>
<class>
...
</class>
<class>
...
</class>
</classes>
<Commitments>
...
</Commitments>
<master>
Use the contains
method, rather than ==
operator.
var bbClasses:XMLList =
xml.classes.class.(students.student.commitments.comm.contains(sport));
ps: Watch out for your case.
"BasketBall
" ins't "Basketball
", so your E4X won't match.
精彩评论