FlashPlaya

May 27, 2009

Create an XMLList using multiple expressions

Filed under: AS 3 — Tags: , — iBen @ 5:42 am

It is actually possible to create an XMLList that meets more than one condition. The way to do this is a bit linear but will works. Each time you compare an XML element with a condition, you are able to follow up the expression with a request. In most cases you would ask for the name of the element or text or attribute, but we can use this to our advantage and keep checking for conditions to return to a list.

consider the usual way to create an XMLList:

myXMLList:XMLList= xml..childElement.(@identification<=3)

As you know my XMLList will be populated with any node that contains an attribute labeled identification that holds a value that is less than or equal to 3.

Now what if i wanted to know what the value was :
myXMLList:XMLList= xml..childElement.(@identification<=3).@identification

this expression will not only populate my list with the following but because i am still on the same index, i can continue to use the current xml node index to retrieve a value, in this case, the current xml Nodes attribute identification which gives me 2.

Utilizing the same method to find out what that value is, we can once again add another condition to choose whether we want to populate our xmlList with the following node.

myXMLList:XMLList= xml..childElement.(@identification<=3).(@identification!=2)

This statement will only push an element into our xmlList that has an attribute labeled identification which must be either 3 or less, but can not be 2.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress