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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:11:41+00:00 2026-05-13T23:11:41+00:00

XML is cool in flex, but I have an annoying problem to solve, caused

  • 0

XML is cool in flex, but I have an annoying problem to solve, caused by what I can imagine is a feature. You see, when you have just one tag of something, it creates an object which is not an array. But when finds more than one, it puts it on an array structure.

I want to solve it elegantly. Any recommendation.

Example: this illustrates it, being the result of a HTTP request:

private function initXMLRes(event:ResultEvent):void
{
    var resObj:Object = event.result;
    //
    for each(var i:Object in resObj.specifictag)
    {
        // to use specifictag attributes, etc. example:
        Alert.show(specifictag.name);
    }
}

The code before will work with 2+ items. It will accept this xml:

<specifictag name="one" /><specifictag name="two" />

… but not this one:

<specifictag name="one" />

I could check the format of resObj.specifictag (to check if it is has an array) and then duplicate the code (for each case). But -even if it’s calling a function- I don’t think it is an elegant solution.

Well, I hope someone has a good idea on this matter. (I know from experience that SO has much more C++ experts than flex, but well…)

The perfect thing would be that HTTPrequest handled every tag in a consistent way (using always arrays… though I’m guessing that that would also have its drawbacks).

Thanks!

  • 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-13T23:11:42+00:00Added an answer on May 13, 2026 at 11:11 pm

    The problem I think is actually a bug, that you can handle in your HTTPService result handler and force your returned object into being an array collection. Here’s a snippet from my app.

    if (evt.result.rows.row is ArrayCollection) {
        MyAC= evt.result.rows.row;
    }else{
        MyAC= new ArrayCollection(ArrayUtil.toArray(evt.result.rows.row));
    }
    

    So it should work for you like this:

    var resObj:Object = new Object();
    
    if (event.result.rows.row is ArrayCollection) {
        resObj= event.result
    }else{
        resObj= new ArrayCollection(ArrayUtil.toArray(event.result));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm pretty new to flex 3 but it's really cool so far. i have
Which XML validation tools can you recommend for both performance and accuracy, each of
An XML attribute declared as xs:boolean can acceptable be true, false, 0 or 1.
I have a complete XML document in a string and would like a Document
I have an XML object (loaded using XMLHTTPRequest 's responseXML ). I have modified
Eclipse has pretty cool JPA Structure and JPA Detail views along with a persistence.xml
Custom metadata in Actionscript classes are very cool. You can put anything in square
I have an xml formatted document that looks like this: <?xml version=1.0 encoding=windows-1250?> <
How can I omit all XML-Namespaces from the xslt in the html-output? My XSL
So I wanted to have a TextView with a cool border around it. 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.