# XML Document in Flash CS3 - Actioncript2

**URL:** <https://forum.kirupa.com/t/xml-document-in-flash-cs3-actioncript2/296493>\
**Category:** flash\
**Created:** [September 15, 2009, 4:54pm UTC](https://forum.kirupa.com/t/xml-document-in-flash-cs3-actioncript2/296493 "2009-09-15T16:54:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mihaispr](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@mihaispr](https://forum.kirupa.com/u/mihaispr)\
**Post date:** [September 15, 2009, 4:54pm UTC](https://forum.kirupa.com/t/xml-document-in-flash-cs3-actioncript2/296493/1 "2009-09-15T16:54:56Z")

</div>

I have a problem using function hasChildNodes() in ActionScript2. Here is the link where I read about that function:

[http://www.adobe.com/support/flash/action\_scripts/actionscript\_dictionary/actionscript\_dictionary839.html](http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary839.html)

I expose in detail my problem.

So first I have an xml document that I attach here:

[http://flyupload.flyupload.com/get?fid=7321293](http://flyupload.flyupload.com/get?fid=7321293)

Ok.

Now the contents of my fla file(on frame1 I put this actionscript code). Put the two files in one folder.

So create a fla file and paste this code:

```auto

// incarca document XML cu nume specificat in FLASH

// cream instanta cu numele xmldocument pt.clasa XML

// xmldocument este un obiect ce apartine clasei XML

var xmldocument:XML = new XML()

// setam proprietate ignoreWhite la true

xmldocument.ignoreWhite = true;

xmldocument.onLoad = function(succes:Boolean):Void
{// variabila succes specifica dk documentul XML a fost incarcat
if(succes)
// definim o variabila pt.nodul radacina numita xmlRoot
 {var xmlRoot:XMLNode = this.firstChild; 
  //referinta la tag-ul titlu -variabila xmlTitlu
  var xmlTitlu:XMLNode = xmlFirstItem.firstChild;
  var xmlFirstItem:XMLNode = xmlRoot.firstChild;

  if (xmlRoot.hasChildNodes())
    {trace("We have child nodes in XML File");
      else trace("No child nodes in XML File");
    }
    
     //avem un singur nod radacina numit <elementradacina>
 }
}

//load the xml file in Flash 

xmldocument.load("elementradacina.xml");

```

And here is my error on this line:

```auto
      else trace("No child nodes in XML File");

```

The error :

```auto

'else' encountered without matching 'if'

```

How I can rewrite my code to get rid of that error?

I want to load my xml file into flash and to display a message if my xml file has child nodes or not using hasChildNodes method.
