How to import XML data?
Please explain with examples
regards
spvr
Please explain with examples
regards
spvr
For example you have an XML file of name "myxml.xml" inside the same directory of your fla with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<myrootnode>
<mychildnode id="1">Something111</mychildnode>
<mychildnode id="2">Something222</mychildnode>
</myrootnode>
var cXmlLoader:URLLoader = new URLLoader();
var cUrlReq:URLRequest = new URLRequest("myxml.xml");
cXmlLoader.addEventListener(Event.COMPLETE, onXmlLoad);
cXmlLoader.load(cUrlReq);
function onXmlLoad(oEvent:Object):void
{
XML.ignoreWhitespace = true;
var cXmlData:XML = new XML(oEvent.target.data);
trace(cXmlData.mychildnode[0]);
trace(cXmlData.mychildnode[1]);
}
If you had more child nodes under each of the child nodes then you could access them by simple dot notation using their node names.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.