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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:03:45+00:00 2026-05-22T13:03:45+00:00

In the following code block if I debug the and look at the var

  • 0

In the following code block if I debug the and look at the var obj.theID it shows as an XMLList. Even though the code traces properly I feel it should be a string not an XMLList.



So my question is how can I get it to assign a string and not an XMLList?

var myXML:XML = new XML(
<panels>
  <panel id="1"/>
  <panel id="2"/>
  <panel id="3"/>
</panels>
);

var panels:XMLList = new XMLList( myXML.children());

trace( panels.length()); // is as expected
for each( var panel:XML in (new XMLList( myXML.children())) ){
    var obj:Object = new Object( );

    // XMLList is assigned here but why? and how can I make it a string?
    obj.theID = panel.@id;

    // id is traced as expected but apparently it is just converting the XMLlist to a string.
    trace( panel.@id)
}
  • 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-22T13:03:46+00:00Added an answer on May 22, 2026 at 1:03 pm

    The AS3 xml parser simply reads any native xml content, either attribute or node data as a string, and can be used as such without type conversion. Which is one of things that makes xml so convenient in flash. But if you check the type, it will return as XML unless you specifically cast it (which is essentially what toString() does).

        for each( var panel:XML in panels ){
        var obj:Object = new Object( );
    
        obj.theID = panel.@id;
    
        // the native type is xml, tho can be read without conversion as a string 
        trace( typeof obj.theID) // type:xml
        trace( typeof panel.@id) // type:xml
    
        // simply cast it to string
        obj.theIDString = String(panel.@id); 
        trace( typeof obj.theIDString) // type:string
    }
    

    — update —

    Of note = XML and XMLlist can be and often are used interchangeably. They each have access to a similar set of methods, but there is an important difference. XML may have exactly one root node, while XMLlist may have several. This may not make much of a difference in normal usage, but depending on the structure of your incoming xml, may be a critical distinction. Normally, I just use the XML type. Here is a good article on xml vs xmllist.

    Cheers

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

Sidebar

Related Questions

I'm trying to debug the following block of Javascript code to see what the
I have the following two code blocks. Code block 1 var checkboxes = $(div.c1
I have the following code block : function testJQueryClick(){ $('#button2').click(function(){ alert ('Debug'); return false;
I have the following code block in my xslt; <xsl:when test=StatusData/Status/Temperature > 27> <td
I have following Code Block Which I tried to optimize in the Optimized section
I'm really stuck on why the following code block 1 result in output 1
I need syntax help with the following code logic: I have a code block
I have the following code on my page: <p align=justify style=font-size:10pt;display:block;height:200px;vertical-align:middle;> Content </p> I
What does {{ ... }} block mean in the following code? class X {
For the following block of code: For I = 0 To listOfStrings.Count - 1

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.