Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-11-2008, 08:34 PM   #1
eliddell
Senior Member
 
eliddell's Avatar
 
Join Date: Sep 2006
Location: boston
Posts: 327
Send a message via AIM to eliddell
Default writing XML with AIR

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
eliddell is offline   Reply With Quote
Old 01-13-2008, 07:20 PM   #2
eliddell
Senior Member
 
eliddell's Avatar
 
Join Date: Sep 2006
Location: boston
Posts: 327
Send a message via AIM to eliddell
Default Never mind

i figured it out... whats wrong with the script above is that my var existing data is an array because of the multiple nodes... thus the commas.. solution:
build the var piece by piece in the for loop

but thanks anyway
eliddell is offline   Reply With Quote
Old 05-11-2010, 05:34 AM   #3
xmen
Registered User
 
Join Date: Jul 2008
Posts: 36
Default

Can you post your solution please?! Im having troubles with the root element when i try to update the xml file,any idea?!

check out my topic -->
http://www.actionscript.org/forums/s....php3?t=238173
xmen is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
writing XML with AIR eliddell ActionScript 3.0 0 01-11-2008 07:59 PM
To the tutorial writing staff: XML portfolio tutorial! richarddd ActionScript 2.0 0 07-12-2007 09:16 AM
help with flash application writing to xml jgoodman Other Flash General Questions 2 05-29-2007 02:27 PM
XML file won't load after writing to it traustid ActionScript 2.0 2 04-25-2007 07:32 PM
releasing xml file from XML.onLoad() sophistikat ActionScript 2.0 2 02-21-2007 07:00 PM


All times are GMT. The time now is 08:20 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.