0
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?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

5 Comments

could u prefer any links related to that?
What server side language do you know? Java? PHP? something else?
actually man there is an xml file.In this so many attributes .i would like to update one attribute value..
yep but as said before, there is no other way I'm aware
yes there need some server side scripting.. like script in php/asp
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.