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

  • Home
  • SEARCH
  • 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 6619225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:56:22+00:00 2026-05-25T20:56:22+00:00

I’m having a bit of problems with simple XML coding. I’m using a simple

  • 0

I’m having a bit of problems with simple XML coding. I’m using a simple flash application to write a XML containing customer data (simple stuff, like phone number, name, email, etc).

I understand how to write XML manually, but my issue comes when I want to create a element inside another element. I’m using AS3.

So, for example, I have the following xml.

<xmlcontainer>
  <client>
    <name>Marco</name>
    <phone>123456789</phone>
  </client>
  <client>
    <name>Roberto</name>
    <phone>987654321</phone>
  </client>
</xmlcontainer>

If I want to add a new element, thats fine. But i’m not sure how to add a element INSIDE once its done in code.

I have been using .appendChild(<client/>) so far, but errors pop up as I do element inside element. I tried writing as a text element (i.e., manually) by just doing .appendChild("<client><name>Marco</name></client>"), but the less than and great than symbols don’t pass along correctly.

Can someone help me out here?

EDIT: As requested, here is the full code.

function appendXML():void{

var xmlData:XML = new XML();
var xmlrequest:URLRequest = new URLRequest(String("xml/clientelist.xml"));
xmlLoader.load(xmlrequest);
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

function LoadXML(e:Event):void
{
        xmlData = new XML(e.target.data);
        xmlData.appendChild(<pessoa/>);
    xmlData.appendChild(<id/>);
    xmlData.id.appendChild(idfield.text);
    xmlData.appendChild(<nome/>);
    xmlData.nome.appendChild(nomefield.text);
    xmlData.appendChild(<email/>);
    xmlData.email.appendChild(emailfield.text);
    xmlData.appendChild(<contacto/>);
    xmlData.contacto.appendChild(contacto1field.text);
        trace(xmlData);

    var fileb:FileReference = new FileReference;
    fileb.save( xmlData, "clientelist.xml" );
}

(pessoa = person, nome = name, contacto = phonenumber)

  • 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-25T20:56:23+00:00Added an answer on May 25, 2026 at 8:56 pm

    I get no errors with your code.
    I modified the text field values and hard coded as a string for testing .
    So what errors are you getting?
    Sounds to me like your xml response from the server might be broken.

    The following code is a working example, although I don’t thinkthe data is structured the way you want.

     var xmlData:XML = new XML(<xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
    </xmlcontainer>
    );
    xmlData.appendChild(<pessoa/>);
    xmlData.appendChild(<id/>);
    xmlData.id.appendChild('idFieldText');
    xmlData.appendChild(<nome/>);
    xmlData.nome.appendChild('nameFieldText');
    xmlData.appendChild(<email/>);
    xmlData.email.appendChild('email');
    xmlData.appendChild(<contacto/>);
    xmlData.contacto.appendChild('phone');
    trace(xmlData);
    
    // output is 
    <xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
      <pessoa/>
      <id>idFieldText</id>
      <nome>nameFieldText</nome>
      <email>email</email>
      <contacto>phone</contacto>
    </xmlcontainer>
    

    // And to build on it dont forget to add CDATA tags to all user input fields.<br/>
    var xmlData:XML = new XML(<xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
    </xmlcontainer>
    );
    var userID:String = '123456789'
    var userName:String = 'John doe'
    var email:String = 'my@email.com'
    var phone:String = '888-555-1212'
    
    xmlData.appendChild(<pessoa/>);
    xmlData.appendChild(<id/>);
    xmlData.id.appendChild( new XML( "\<![CDATA[" + userID + "]]\>" ));
    xmlData.appendChild(<nome/>);
    xmlData.nome.appendChild( new XML( "\<![CDATA[" + userName + "]]\>" ));
    xmlData.appendChild(<email/>);
    xmlData.email.appendChild( new XML( "\<![CDATA[" + email + "]]\>" ));
    xmlData.appendChild(<contacto/>);
    xmlData.contacto.appendChild( new XML( "\<![CDATA[" + userID + "]]\>" ));
    trace(xmlData);
    
    //output is 
    <xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
      <pessoa/>
      <id><![CDATA[123456789]]></id>
      <nome><![CDATA[John doe]]></nome>
      <email><![CDATA[my@email.com]]></email>
      <contacto><![CDATA[123456789]]></contacto>
    </xmlcontainer>
    

    // to expand farther and clean up
    
    var xmlData:XML = new XML(<xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
    </xmlcontainer>
    );
    var userID:String = '123456789'
    var userName:String = 'John doe'
    var email:String = 'my@email.com'
    var phone:String = '888-555-1212'
    
    
    
    var client:XML = new XML(<client/>)
    //client.appendChild(<id/>);
    client.appendChild( new XML( "<id>\<![CDATA[" + userID + "]]\></id>" ));
    client.appendChild( new XML( "<nome>\<![CDATA[" + userName + "]]\></nome>" ));
    client.appendChild( new XML( "<email>\<![CDATA[" + email + "]]\></email>" ));
    client.appendChild( new XML( "<contacto>\<![CDATA[" + userID + "]]\></contacto>" ));
    
    xmlData.appendChild(client);
    
    trace(xmlData);
    
    // output is
    <xmlcontainer>
      <client>
        <name>Marco</name>
        <phone>123456789</phone>
      </client>
      <client>
        <name>Roberto</name>
        <phone>987654321</phone>
      </client>
      <client>
        <id><![CDATA[123456789]]></id>
        <nome><![CDATA[John doe]]></nome>
        <email><![CDATA[my@email.com]]></email>
        <contacto><![CDATA[123456789]]></contacto>
      </client>
    </xmlcontainer>
    

    And to sum up your question.
    When you add a node “client” in your case you can only target it in 2 ways.
    The first way is to create an XMLList and loop through it until you find the one you are looking for. This is due to the fact that you have multiple “clients”.

    The second method would be to Id the clients somehow for example an attribute.

    If you know the Id you can target that specific node easy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

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.