Quick Tip: Test to see if an XML attribute is present

Today I received a question about how to check and see if an attribute is present into a XML node.

I thought it wold be a good idea if I post the answer here in case someone else needs to do the same.

This is the ActionScript code:

if(node.@attributeName in node)
    //the attribute is here

As you can see, the code is very simple, “node” is your actual XML node and “attributeName” is exactly what it says, the name of your attribute inside the XML node (the one that you are checking to see if it is there).