Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Desktop, Mobile and non-browser Environments > AIR (Apollo)

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-11-2008, 09:34 PM   #1
eliddell
Senior Member
 
eliddell's Avatar
 
Join Date: Sep 2006
Location: boston
Posts: 250
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, 08:20 PM   #2
eliddell
Senior Member
 
eliddell's Avatar
 
Join Date: Sep 2006
Location: boston
Posts: 250
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
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 08:59 PM
To the tutorial writing staff: XML portfolio tutorial! richarddd ActionScript 2.0 0 07-12-2007 10:16 AM
help with flash application writing to xml jgoodman Other Flash General Questions 2 05-29-2007 03:27 PM
XML file won't load after writing to it traustid ActionScript 2.0 2 04-25-2007 08:32 PM
releasing xml file from XML.onLoad() sophistikat ActionScript 2.0 2 02-21-2007 08:00 PM


All times are GMT. The time now is 09:41 AM.


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