Copy link to clipboard
Copied
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(cUr
...Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Adobe Forum (but i think YOU) wrote:
thanks harry.
i have a another problem with xml data load if i use class.
please check following code
package {
import flash.xml.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.errors.IOError;
import flash.events.IOErrorEvent;
import flash.display.MovieClip;
public class xmldata {
public var loader:URLLoader = new URLLoader();
public function xmldata() {
loader_fun();
}
private function loader_fun(){
loader.addEventListener(Event.COMPLETE, onLoadXML);
loader.load(new URLRequest("carData.xml"));
}
public function onLoadXML(ev:Event) {
try {
var myXML:XML = new XML(ev.target.data);
trace(myXML);
} catch (e:TypeError) {
trace("Could not parse the XML");
trace(e.message);
}
}
}
}
Copy link to clipboard
Copied
you can try this example.it uses URLLoader in flex to extract XML data
http://flexparsexml.blogspot.com/