• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

xml help looping through

New Here ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

252

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

what's myList1 look like?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

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,

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

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);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

here is part of the xml i have to work with

<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">

<channel>

<title>Amherst Chamber of Commerce Events</title>

<description>

Discover what is happening with the Amherst Chamber of Commerce.

</description>

<pubDate>Mon, 01 Jun 2015 09:15:14 -0400</pubDate>

<generator>Fission</generator>

<link>http://www.amherst.org</link>

<item>

<title>June Business Before Hours</title>

<description>

<![CDATA[ June Business Before Hours ]]>

</description>

<pubDate>Tue, 26 May 2015 12:11:10 -0400</pubDate>

<content:encoded>

<![CDATA[ June Business Before Hours ]]>

</content:encoded>

<slash:comments>0</slash:comments>

</item>

<item>

<title>Every Vote Counts - Yours Matters</title>

<description>

<![CDATA[

The Museum of disABILITY History is happy to host "Every Vote Counts—Yours Matters," an accessible voting training event, on Monday, June 1, 2015, from 10:30 a.m. to 2:30 p.m. at 3826 Main Street, Buffalo. Attendees can learn how to use machines that make voting possible for those who are blind, visually impaired or otherwise unable to mark a traditional ballot. There will be an explanation of accessible voting machines as well as a mock debate featuring self-advocates B.J. Stasio and Darren Jackson. Those in attendance can then determine the debate outcome by using accessible machines. Refreshments will be provided. Sponsored by the New York State Office for People with Developmental Disabilities and the Erie County Board of Elections, the event is free and open to the community. For more information, or to register, call the Museum of disABILITY History at 716-629-3626.

]]>

</description>



as you can see, it has different events, I need to sort these and loop through them.


I tried the title loop you suggest but to no avail.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

LATEST

if the loop i suggested doesn't work, you need to check myList1.

in fact, just trace what you load.  it that's what you showed, replace myList1 with what you loaded.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines