Use e4x, most e4x expressions return an XMLList. Then check if the
result has a length greater than 0. Some of the alternatives are
actually more work computationally, as they do the test for existence
and then run the query later if it exists. Here is an example of where
I use it.
var previewsElement:XMLList = xml.previews;
if(previewsElement.length()>0) {
//do stuff here
}
In some cases I just get the list and iterate over it, then if the list
is empty it just moves on.
Paul
John M. Resler wrote:
> Hello all,
> I'm pretty new to this dynamic web content thing and I'm wondering
> how to deal with the AS3 XML set of objects. In particular, how do you
> program to deal with an element that may not be there at runtime? In
> specific, RSS has no official schema and so some people don't include
> all of the elements. If I reference an XML element that does not exist
> I get an exception. Is there a way to detect the existence of an
> element? Thanks for your help.
>
> - J.R.
>
> A people that values their privileges
> over their principles, will soon lose
> both.
>
> - Dwight "Ike" Eisenhower
>
>