# Checking wheather an attribute exist in node or not

**URL:** https://forum.kirupa.com/t/checking-wheather-an-attribute-exist-in-node-or-not/244840
**Category:** flash
**Created:** [November 22, 2007, 12:05pm UTC](https://forum.kirupa.com/t/checking-wheather-an-attribute-exist-in-node-or-not/244840 "2007-11-22T12:05:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![psych](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/psych/32/2839_2.png) [@psych](https://forum.kirupa.com/u/psych)
#### Post date: [November 22, 2007, 12:05pm UTC](https://forum.kirupa.com/t/checking-wheather-an-attribute-exist-in-node-or-not/244840/1 "2007-11-22T12:05:05Z")

</div>

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

```auto

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

```

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

```auto
if (xml.attribute("id") == null){
  trace("Attribute doesn't exist...");
}else{
  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
