Checking wheather an attribute exist in node or not

Let’s say i have the following simple xml structure:

var xml:XML = new XML (<test id="test">

And i would like to test wheather ‘id’ attibute exists in ‘test’ node or not. I tried with:

if (xml.attribute("id") == null){
  trace("Attribute doesn't exist...");
  trace ("Attribute exists...");

But i get ‘Attribute exists’ wheather it really exists or not :ponder: How can i check wheather an attribute exists or not?

thanks in advance,
best regards