im trying to open an existing XML document and then write to it with AIR using flash..
ActionScript Code:
import flash.filesystem.File;
import flash.filesystem.FileStream;
import flash.filesystem.FileMode;
var appDir:File = File.applicationStorageDirectory
var dskTopFileStream:FileStream = new FileStream();
var fileString:String = appDir.nativePath;
var dskTopFile:File = File.documentsDirectory;
trace(dskTopFile);
dskTopFile = dskTopFile.resolvePath(fileString+"\\bankroll.xml");
// LOAD XML
var xmlString:URLRequest = new URLRequest(fileString+"\\bankRoll.xml");
var xmlLoader:URLLoader = new URLLoader(xmlString);
xmlLoader.addEventListener("complete", init);
var defaultXML:XMLDocument = new XMLDocument();
defaultXML.ignoreWhite = true;
function init(event:Event):void {
var xml:XML = XML(xmlLoader.data);
defaultXML.parseXML(xml.toXMLString());
//var myString:String = defaultXML.firstChild
var existingData = defaultXML.firstChild.childNodes
trace(existingData)
var i = 0
for (i=0;i<defaultXML.firstChild.childNodes.length-1;i++) {
trace(i)
}
dskTopFileStream.openAsync (dskTopFile, FileMode.WRITE);
dskTopFileStream.writeUTFBytes ("<BankRoll>"+ existingData+existingData+"</BankRoll>");
dskTopFileStream.close ();
}
problem is, it keeps inserting weird charecters and placing commas etc between my childNodes.. this effect seems much like an old php problem i use to encounter having something to do with a setting in the php server..
any ideas?
erik
eliddell is online now Report Post Edit/Delete Message