|
by
kirupa | 17 July 2007
In the previous page,
you learned how to filter your data based on conditions that you set. In all of the previous filtering examples,
though, you only filtered your values
based on one condition. You can actually have as many conditions as you want, so
you can create sophisticated filters for precisely find the data you need.
For example, try the following code:
- function
ParseBooks(bookInput:XML):void
{
- trace("XML
Output");
- trace("------------------------");
-
- var
bookList:XMLList
=
bookInput.Book.(author
==
"Stephen E. Ambrose" &&
title
!=
"Nothing Like It In the World").title;
- trace(bookList);
- }
When you test your application with the above code, Undaunted Courage will be
the only returned result. Notice that we are filtering our data by both author
and title. The author must be Stephen E. Ambrose, but the title cannot be
Nothing Like It In the World.
Hopefully the previous six pages provided you with enough
tools to tackle even the most demanding XML-related tasks.
The introduction of E4X in AS3 is quite significant and
makes dealing with XML data easier. With the ease, though,
comes a relatively different (sometimes complicated) syntax
for accessing the data, and this tutorial only covered a
sub-set of all that is possible under E4X.
Throughout this tutorial, you used a sample XML file that
contained four of my favorite books. Below, I have provided
the cover image and an Amazon link where you can learn more
or even buy them:
Need Help?
If you have questions, need some assistance on this topic, or just want to
chat - please drop by our friendly forums
and post your question. There are a lot of knowledgeable and witty people who
would be happy to help you out. Plus, we have a
large collection of smileys
you can use

Share
Did you enjoy reading this and found it useful? If so, please share it with
your friends:
If you didn't like it, I always like to hear how I can do better next time.
Please feel free to contact me directly at kirupa[at]kirupa.com.
Cheers!
|