# Illegal function help..simplify xml import

**URL:** <https://forum.kirupa.com/t/illegal-function-help-simplify-xml-import/296612>\
**Category:** flash\
**Created:** [September 17, 2009, 8:43am UTC](https://forum.kirupa.com/t/illegal-function-help-simplify-xml-import/296612 "2009-09-17T08:43:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goeiste](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/goeiste/32/2741_2.png) [@goeiste](https://forum.kirupa.com/u/goeiste)\
**Post date:** [September 17, 2009, 8:43am UTC](https://forum.kirupa.com/t/illegal-function-help-simplify-xml-import/296612/1 "2009-09-17T08:43:01Z")

</div>

Hello,

For an application I’m making I need some dedicated xml import. To simplify this import I want to have a function (because I need a repetitive process). The only thing is that I want to change parameters inside a xml string as well. All in all my function does not work. I’ve added the code below. The function I’m talking about is:

function checkPercentage(intPer:Number, textfield, xmlText):void

```auto
var intPer1:Number = 30;
var intPer2:Number = 60;

function showXML(event:MouseEvent)
{
	var intent_xml:XML;
	var xmlReq:URLRequest = new URLRequest("intent.xml");
	var xmlLoader:URLLoader = new URLLoader();

	function checkPercentage(intPer:Number, textfield, xmlText):void
	{
		if(intPer < 33){
			textfield.text = intent_xml.xmlText.low;
		}else if(intPer < 66){
			textfield.text = intent_xml.xmlText.medium;
		}else{
			textfield.text = intent_xml.xmlText.high;
		}
	}

	function dataLoaded(event:Event):void
	{
		intent_xml = new XML(xmlLoader.data);
		//give proper description for low/medium/high 
		checkPercentage(intPer1, intentI_txt, intent_I);
		checkPercentage(intPer2, intentII_txt, intent_II);
			
	}
	
	xmlLoader.addEventListener(Event.COMPLETE, dataLoaded);
	xmlLoader.load(xmlReq);
}

process_btn.addEventListener(MouseEvent.CLICK, showXML);

```

Can someone point me in the right direction?
