write, update and save a well-formed xml file in as3

venomsseo

New Member
I am trying to update an xml file and save elements inside of an already saved root element.I have only found examples where the xml files are just opened and not saved. Can someone help me to find the best way to save the results?My project right now looks like this:I am loading an xml file via URLLoader/URLRequest and display the contents in several text fields. New text from an input field is saved (appended) via FileStream directly to the xml file in the applicationStorageDirectory (that will be on iPhone).The new input should then be added to an on-screen list (created with a for-loop) and displayed, however, it can't get it that far. After reading the newly saved input from the xml file, I naturally get error 1088 because the xml file is not well-formed anymore.This is because the input is appended after the root element and the result looks like this:\[code\]<root> <message></message> <date></date></root> <message>new input</message> <date></date>\[/code\]When of course what I want is this:\[code\]<root> <message></message> <date></date> <message>new input</message> <date></date></root>\[/code\]But I have no idea how i can achieve that.I made several attempts to avoid having to append, like loading the xml content, changing it, and then writing everything again. But since I am still new to as3 I couldn't get it to work.It would be great if someone could tell me what the best way to go would be and maybe how to solve it.
 
Back
Top