Hi,
I have used loadXMl.as file for XML to Object conversion till date. I am now converting the framework from AS1 to AS3.
Is there any alternate in AS3 for XML to Object conversion other than using the XML class. I am facing a lot of problems with XML class which I am not used to.
Here is the example
XML file
<?xml version="1.0" encoding="UTF-8"?>
<globalconfig>
<default_language><![CDATA[English]]></default_language>
<default_language_flag><![CDATA[en_gb]]></default_language_flag>
</globalconfig>
AS code
var xmlLoader:URLLoader = new URLLoader();
var configXML:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadConfigXML, false, 0, true);
xmlLoader.load(new URLRequest("config.xml"));
function LoadConfigXML(e:Event):void
{
configXML = new XML(e.target.data);
trace(configXML.default_language);
trace(typeof(configXML.abc));
xmlLoader.removeEventListener(Event.COMPLETE, LoadConfigXML);
}
The 2nd trace command shows
**xml
**
though I expect it to show undefined as the tag does not exist in the XML file. Same problem is with attributes.