I’ve often faced the issue of having to use an XML attribute that may not always be present. I wanted to ensure I don’t receive any NullPointerExceptions trying to parse an attribute that’s not there, so here’s a quick and easy way to check.
var xmlNode:XML = <node attr1="this is a test"/>
if (String(xmlNode.@attr1).length > 0)
trace("No Attr1 exists");