Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7004053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:08:59+00:00 2026-05-27T21:08:59+00:00

I am playing around with saving .xml files from data in my game. I

  • 0

I am playing around with saving .xml files from data in my game. I know how to convert an xml object to a ByteArray and write that to a FileReference. What I need to know now is how to go from an empty xml object (using var xml:XML = new XML()) to a fully populated xml object.

Can someone show me what functions to use to add nodes and values? Specifically I need to know how to make several of the same type of node. Here’s a sample of what the final xml should look like:

<data>
    <player>
        <money>15831</money>
        <shipType>1</shipType>
        <ship>
            <fuelCur>450</fuelCur>
            <energyCur>160</energyCur>
            <shieldCur>100</shieldCur>
            <armorCur>40</armorCur>
            <structCur>15</structCur>
        </ship>
    </player>
    <currentSystem>3</currentSystem>
    <currentPlanet>3</currentPlanet>
    <date>
        <year>2012</year>
        <month>10</month>
        <day>15</day>
    </date>
    <missionFlag>true</missionFlag>
    <planet id="0">
            <population>0</population>
    </planet>
    <planet id="1">
            <population>29827632</population>
    </planet>
    <planet id="2">
            <population>0</population>
    </planet>
</data>

It might be useful to know how to remove and how to alter nodes and values, too.

Also, do I need to import something from the flash library to do this with XML? I’m using FlashDevelop, but when I type xml., FlashDevelop doesn’t bring up suggestions like it normally does.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:08:59+00:00Added an answer on May 27, 2026 at 9:08 pm

    Editing XML in AS3 is actually pretty easy and pretty basic – it’s a core part of AS3. AS3 automatically adds nodes as you call them, like so:

    var xml:XML = <data />;
    xml.player.money = 15831;
    xml.player.shiptype = 1;
    xml.player.ship.fuelCur = 450;
    

    Will result in:

    <data>
        <player>
            <money>15831</money>
            <shiptype>1</shiptype>
            <ship>
                <fuelCur>450</fuelCur>
            </ship>
        </player>
    </data>
    

    Then to add multiples of the same node, just start a new XML object of the type you want, and append it to the XML object you’re working on. Or skip the separate xml object entirely. Repeat as many times as needed:

    var segment:XML = <planet />;
    xml.appendChild(segment); // xml.planet[0]
    xml.appendChild(segment); // xml.planet[1]
    xml.appendChild(<planet />); // xml.planet[2]
    //etc...
    

    Then you can add values to them by their indexes.

    //Assuming this is the 4th planet you've added...
    xml.planet[3].population = 29827632;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
After playing around with haskell a bit I stumbled over this function: Prelude Data.Maclaurin>
I'm playing around with the <canvas> element, drawing lines and such. I've noticed that
While playing around with the emulator, I noticed that when trying to view a
I have an MVC 2.0 application that I'm playing around with in VS2010 which
playing around with a property file i figured that there seems to be a
I'm playing around with this idea where i was saving logs in a LOGS
I've been investigating alternative methods for saving my game's data between turns, and wonder
I come from a web-development background. I've been playing around with a bit of
I playing around with the sftp example from here: Stackoverflow: twisted conch filetransfer I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.