Reputation: 443
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?
Upvotes: 0
Views: 533
Reputation: 94
The only way you can modify a file trough flash is either local storage within Air or server side scripting and passign the modifications to the server (either the whole xml or just the changes), but no way to modify remotely xml file. In it's the xml file is a static structure and for the OS it's simply an ASCII file.
Upvotes: 1
Reputation: 8875
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
Upvotes: 1