Skip to main content
Known Participant
June 1, 2015
Question

xml help looping through

  • June 1, 2015
  • 1 reply
  • 424 views

can you please help me with some xml looping and sorting?

at this URL: Amherst Chamber of Commerce Events

contains an xml file that I have to work with.

I am trying to loop through it to grab the number of title tags/events and put them into an array. I need to build this dynamically because the number of events and titles can change at anytime.

here is what I have so far,

(I already have the code needed to download xml, the following code is after this point)

var myList1:XMLlist = myxml.channel;

for each (var title:XML in myList1)

{

     trace(title)// this is not working, only traces 1st title in xml

//I probably need a nested loop here,

}

thanks in advance for your help.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
June 1, 2015

what's myList1 look like?

v4varun22Author
Known Participant
June 1, 2015

please see the url of the xml attached,

I am not even sure if myList1 should be = to myxml.channel

how would you pull each node/tag and pull its events into an array?

thanks,

kglad
Community Expert
Community Expert
June 1, 2015

i don't see anything attached.  and use the trace function to debug myList1.

if it has title descendents, use:

for(var i:int=0;i<myList1..title.length();i++){

trace(myList1..title);

}