I've got an XML file that I open and do some changes with inside my app, and I need to be able to save it out to a new file.
Now I'm using this code to save it to the same file:
var fs:FileStream = new FileStream();
fs.open(myOpenXML, FileMode.WRITE);
fs.writeUTFBytes(myXMLString);
fs.close();
If I trace myXMLString I get proper formatting (new line for every object in the XML), but when I save it out, everything ends up on one line.. How come? And I want to save to a new file, how do I do that? (using save dialog box).
I'm using Flash Builder. Flex, AS3, AIR..
Thanks a lot for your time and help ;)
I'll answer a part of your question, about saving to a new file using Save Dialog box. You will be using a FileReference
to do this.
Here is a snippet I copied from this article which I suggest you read.
private var _loadFile:FileReference;
private function startLoadingFile():void
{
_loadFile = new FileReference();
_loadFile.addEventListener(Event.SELECT, selectHandler);
var fileFilter:FileFilter = new FileFilter("Images: (*.jpeg, *.jpg, *.gif, *.png)", "*.jpeg; *.jpg; *.gif; *.png");
_loadFile.browse([fileFilter]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.