var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onLoaad);
ldr.load(new URLRequest("oman.xml"));//or any script that returns xml
function onLoaad(e:Event):void
{
var loadedText:String = URLLoader(e.target).data;
trace(loadedText);
//create xml from the received string
var xml:XML = new XML(loadedText);
trace(xml.toXMLString());
//modify it
var word2:XML = <word/>;
var name:XML = <name/>;
name.appendChild("the name");
word2.appendChild(name);
var title:String = "asdasd";
word2.appendChild("<title2>" + title + "</title2>");
xml.appendChild(word2);
trace(xml.toXMLString());
//save it
var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onSave);
//listen for other events here.
var data:URLVariables = new URLVariables();
data.xml = xml.toXMLString();
var req:URLRequest = new URLRequest("oman.xml");
req.data = data;
ldr.load(req);
}
function onSave(e:Event):void
{
trace(e.target.data);
}
Here i have written code for the ml structure
<words>
<word>
<name>this</name>
<title>that</title>
</word>
</words>
But no update is happening here.. is there any alternative methods to it?
URLLoader.load method only ... load data. You can't save content by calling URLLoader.load.
If you only work on local content (on your own computer), you could use the FileReference class. If your XML is stored on a server, you need some server side script to save the data