Accessing descendants
var xml:XML = <LOAN>
<BOOK ISBN="976568989" DATE="1136091600000">
<TITLE>Ulysses</TITLE>
<AUTHOR>Joyce, James</AUTHOR>
<PUBLISHER>My Books</PUBLISHER>
</BOOK>
<DVD ISBN="5432334456" DATE="1136691000000">
<TITLE>2001 A Space Odysses</TITLE>
<DIRECTOR>Stanley Kubrick</DIRECTOR>
<PUBLISHER>Warner</PUBLISHER>
</DVD>
<DVD ISBN="7878785566" DATE="1136691000000">
<TITLE>Toy Story</TITLE>
<DIRECTOR>John Lasseter</DIRECTOR>
<PUBLISHER>Walt Disney</PUBLISHER>
</DVD>
</LOAN>
<BOOK ISBN="976568989" DATE="1136091600000">
<TITLE>Ulysses</TITLE>
<AUTHOR>Joyce, James</AUTHOR>
<PUBLISHER>My Books</PUBLISHER>
</BOOK>
<DVD ISBN="5432334456" DATE="1136691000000">
<TITLE>2001 A Space Odysses</TITLE>
<DIRECTOR>Stanley Kubrick</DIRECTOR>
<PUBLISHER>Warner</PUBLISHER>
</DVD>
<DVD ISBN="7878785566" DATE="1136691000000">
<TITLE>Toy Story</TITLE>
<DIRECTOR>John Lasseter</DIRECTOR>
<PUBLISHER>Walt Disney</PUBLISHER>
</DVD>
</LOAN>
theElement..identifier
A descendant operator(..) returns a XMLList representing all descendants of theElement whose name match identifier.
i.e. xml..DIRECTOR//Notice that the <DIRECTOR> elements are not direct children of the <LOAN> element; they are grandchildren.
Above expression yields an XMLList that has two XML instances, representing the two <DIRECTOR> elements.
Example
for each(var title:XML in load..TITLE)
trace(title);
trace(title);
//Output
Ulysses
2001 A Space Odysses
Toy Story
Ulysses
2001 A Space Odysses
Toy Story
theElement..@attributeName
A descendant operator also works with attributes(..@) returns a XMLList representing all descendants attributes of theElement whose name match attributeName.
i.e. xml..@DUEAbove expression yields an XMLList that has three XML instances, representing the three DUE attributes.
0 Responses to ActionScript 3.0 - Manage Xml Obj
Part 3
Something to say?