Join Todd Perkins for an in-depth discussion in this video Working with an XMLList, part of ActionScript 3.0: Working with XML.
Now we will talk about how to access our XML elements using something called an XMLList. If you are following along, I am working in 03_XMLList.fla in the Chapter 3 folder. You can also use the same file you have been working with throughout this chapter. Let's go to the first keyframe of the Actions layer and open up the Actions Panel. So let's say we wanted to access the first image element in our gallery. So instead of putting Gallery.XML.2xml string in our text field, I am going to put Gallery.XML.image. Let's test the movie and see what we get.
Notice here I am just getting the two child elements of our gallery, they are both called Image. These are what are called Sibling Elements and because these siblings have the same name, there is something called Repeating Elements. Now when you have Repeating Elements inside of an XML object that creates something called an XMLList. An XMLlist is similar to an array of XML data and there is special syntax to working with elements in an XMLList. So one thing we can do is right after image, I can type some brackets and put a 0 referring to index 0.
If I test the movie at this point then I will just get the first image and now I can reference that element as if it were a single XML element. So say I wanted to get the title of that element, I could just type .title. And so if I wanted to get the photographer's ID, I could type .photographer.attribute ID, and there is the photographer ID. So we can access elements in an XMLList using square brackets, just like referencing an element in an array. In the next few movies we will dive deeper into XMLList syntax.
- Understanding XML data
- Creating XML in ActionScript 3.0
- Working with external XML data
- Building a reusable RSS reader class
- Using PHP with XML
- Working with blogs
- Working with Flickr images using the Flickr API
- Working with podcasts
Skill Level Intermediate
1. Understanding XML Data
2. Creating XML in ActionScript 3.0
3. Working with External XML Data
4. Building a Reusable RSS Reader Class
Exploring an RSS file3m 1s
5. Using PHP with XML Data
6. Working with Blogs
7. Working with the Flickr API
8. Working with Podcasts
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.