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 459165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:44:43+00:00 2026-05-12T22:44:43+00:00

I am trying to get the child XML tag names in my AS3 program.

  • 0

I am trying to get the child XML tag names in my AS3 program. For example, I have a file with information like this:

<LocationInfo>
   <City>New York City</City>
   <State>NY</State>
   <Zip>10098</Zip>
</LocationInfo>

I load the file into an ArrayCollection and can access each item I need by name such as
[“City”] // Returns New York

Instead of getting the value, what I am trying to do is get the tag name such as State or Zip instead of NY or 10098.

  • 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-12T22:44:44+00:00Added an answer on May 12, 2026 at 10:44 pm

    When dealing with XML, you’re almost always better off using an XMLListCollection. For the most part, you wont’s ACTUALLY need the additional functionality of an ArrayCollection and the XMLListCollection will certainly make things a lot easier. Further, ArrayCollections don’t always serialize things correctly. I can’t give you a specific circumstance, but I do know that I have had to refactor because the XML wasn’t properly stored. Finally, XMLListCollection.toXMLString() will give you a far better view of the data’s state than ArrayCollection.toString ever could.

    With an XMLListCollection, what you’re looking for would be done in one of the following:

    var coll:XMLListCollection = <xml-here/>
    
    // Iterate through all of the children nodes
    for( var i:int = 0; i < coll.children().length(); i++ )
    {
        var currentNode:XML = coll.children()[ i ];
        // Notice the QName class?  It is used with XML.
        // It IS NOT a String, and if you forget to cast them, then
        // currentNode.localName() will NEVER be "city", even though it may
        // trace that way.
        var name:QName      = currentNode.name(); // url.to.namespace::city
        var locName:QName   = currentNode.localName() // City
    }
    
    // get all city nodes in the current parent element
    var currCities:XMLList = currentParentNode.cities; // currentParentNode can be 
    // an XMLList, an XML object, an XMLListAdapter, or an XMLListCollection.
    // This means that you can do something like coll.cities.cities, if there are
    // children nodes like that.
    for( i = 0; i < cities.length(); i++ )
    {
        var currentCity:XML = cities[ i ];
    }
    
    // get all city nodes in all descendant nodes.
    var cities:XMLList = currentParentNode.descendants( 
                             new QName( "url.to.namespace", "City" ) 
                         );
    for( i = 0; i < cities.length(); i++ )
    {
        var currentCity:XML = cities[ i ];
    }
    

    If you really MUST use ArrayCollection, then you can use the for… in syntax to achieve what you want:

    // This is one of the few times I recommend anonymous typing.  When dealing with
    // XML (which likely has already been turned into a String anyway, but be safe )
    // anonymous syntax can give you better results.
    
    // it = iterant, I use this to contrast with i for my sanity.
    for(var it:* in coll) 
    {
        trace(it,"=",coll[ it ]);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get my css / C# functions to look like this: body {
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
So I gotta deal with some xml that looks like this: <ns2:foobarResponse xmlns:ns2=http://api.example.com> <duration>206</duration>
I am trying to read the below xml file and get the name-value pairs
I have the following XML, I am trying to get the unique nodes based
I am trying to extract information from an XML file into an object using
I'm trying to find a way to get the total number of child nodes
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
Trying to get a JSON output to work with jqGrid 'userdata' option. The example

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.