2/13/2011 10:30:26 PM
Title:
Help me Pls --Flex XML
I have a XML file like below.. I want to get the exact data of a certain page..
For Example:
i want to get the page with node id: 1400
I want to store the location like this dynamically:: course.topic[0].page[0].topic[0].topic[0].page[0]
How can i get like this.. I don't know how to use for loop for this.. Can anyone help me pls?? It would be very useful.. Thanks in Advance.
<course nodeId="1490" name="Sample Scorm Course" type="course" >
<topic nodeId="1460" name="Introduction" type="topic" index="1">
<page nodeId="1460" src="Swfs/Track1.swf" name="Page 1" text="Sample" index="1"></page>
<page nodeId="1461" src="Swfs/Track2.swf" name="Page 2" text="Sample" index="2" type="interactive"></page>
<topic nodeId="1477" name="Four" type="topic" index="5">
<page nodeId="1478" src="Swfs/Track7.swf" name="Page 15" text="Sample" index="15"></page>
<topic nodeId="1481" name="Four" type="topic" index="7">
<page nodeId="1400" src="Swfs/Track7.swf" name="Page 17" text="Sample" index="17"></page>
<topic nodeId="1489" name="Four" type="topic" index="7">
<page nodeId="1500" src="Swfs/Track7.swf" name="Page 17" text="Sample" index="17"></page>
</topic>
</topic>
</topic>
</topic>
<topic nodeId="1463" name="One" type="topic" index="2">
<page nodeId="1464" src="Swfs/Track4.swf" name="Page 4" text="Sample" index="4"></page>
<page nodeId="1465" src="Swfs/Track5.swf" name="Page 5" text="Sample" index="5"></page>
<page nodeId="1466" src="Swfs/Track6.swf" name="Page 6" text="Sample" index="6"></page>
<page nodeId="1467" src="Swfs/Track7.swf" name="Page 7" text="Sample" index="7"></page>
</topic>
</course>
3/1/2011 1:58:26 PM
You should really think about using E4X as your XML traversal rather than array-index based. It makes it so much easier to get to the particular part of your XML doc that you want.
http://www.adobe.com/devnet/flash/articles/filtering_data_e4x.html