buddyp450
buddyp450

Reputation: 572

Performing an XML search on an attribute that may not exist (E4X)

I want to do something like your standard XML E4X attribute check to return an XMLList of results:

myXml.someGroup.someItem.(@someAttribute == myVar)

Is there a way to do this when @someAttribute doesn't always exist? It's okay if I skip items without the attribute in my search.

Thanks.

Upvotes: 1

Views: 143

Answers (1)

Nicolas Siver
Nicolas Siver

Reputation: 2885

Yes, you could check for property before access it:

myXml.someGroup.someItem.(hasOwnProperty("@someAttribute") && @someAttribute == myVar)

Upvotes: 1

Related Questions