Skip to main content
Known Participant
April 23, 2013
Question

write in XML dynamically

  • April 23, 2013
  • 2 replies
  • 629 views

This is first time I'm trying to write in XML, so I'm sorry if this is a simple question. I have a textbox on the field which will be used for entering names, and I created XML tags using

var objs:XML = new XML( <objects /> );

var objname:XML = new XML ( <objectname /> );

objs.appendChild( objname); // add the <name> node to <objects>

I hope to have a XML structure of

<object>

<objectname>james</objectname>

<objectname>jennice</objectname>

<object/>

But I do not know how to write from textbox in flash to the xml file, or dynamicly create a xml from as3. Please help, thanks in advance.

This topic has been closed for replies.

2 replies

Inspiring
April 24, 2013

But I do not know how to write from textbox in flash to the xml file, or dynamicly create a xml from as3.

Flash alone can`t write to a users (or your own) filesystem you will need to look into AIR (publish your flash to AIR for Desktop to have access to the Filesystem). If you want the user allow to write a xml file serverside you will want to make use of a technology like php or asp in combination with flash.

kglad
Community Expert
Community Expert
April 24, 2013

(that's not true:  check the FileReference class'es save method.)

Inspiring
April 24, 2013

You`re right, that fact has somehow escaped me.

kglad
Community Expert
Community Expert
April 23, 2013

use something like:

var objs:XML = new XML( <objects /> );

function addNameF():void{

var objname:XML = new XML ( <objectname /> );

objs.appendChild( objname); // add the <name> node to <objects>

objname.nodeValue = yourtextfield.text;

}