# Setting error message when loadXml fail

**URL:** <https://forum.kirupa.com/t/setting-error-message-when-loadxml-fail/284718>\
**Category:** Uncategorized\
**Created:** [March 22, 2009, 11:20pm UTC](https://forum.kirupa.com/t/setting-error-message-when-loadxml-fail/284718 "2009-03-22T23:20:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruiganga](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ruiganga/32/3679_2.png) [@ruiganga](https://forum.kirupa.com/u/ruiganga)\
**Post date:** [March 22, 2009, 11:20pm UTC](https://forum.kirupa.com/t/setting-error-message-when-loadxml-fail/284718/1 "2009-03-22T23:20:09Z")

</div>

Hi

I need to have an error message inside a textbox when the xml is not loaded:

My code is simples and is working:

var xmlURL:String ="[http://somesite.com/somefile.xml](http://somesite.com/somefile.xml)

loadBtn.addEventListener(MouseEvent.CLICK, clickLoadBtn);

function clickLoadBtn(e:MouseEvent):void {  
xmlURL=url.text;  
trace(“click load”);  
trace(xmlURL);  
statusvar.text=“loading XML…”;  
////////  
var xmlLoader:URLLoader = new URLLoader();  
var xmlData:XML = new XML();

```
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest(xmlURL));

function LoadXML(e:Event):void {
	xmlData=new XML(e.target.data);
	trace(xmlData);
	xmltext.text = xmlData;
	statusvar.text="XML loaded! If you want to save in a different location or file name please change the URL on top.";
}

```

}

How do I check if the loadXml worked and if not show an error message inside my statusvar textfield.

Thanks 🙂
