Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

write in XML dynamically

New Here ,
Apr 23, 2013 Apr 23, 2013

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.

TOPICS
ActionScript
593
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 23, 2013 Apr 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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 24, 2013 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2013 Apr 24, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Apr 24, 2013 Apr 24, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 24, 2013 Apr 24, 2013
LATEST

(the save method wasn't available when the filereference class was first introduced.  it was quietly added later and i didn't find out about it until i posted a message similar to your's and someone else corrected me.)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines