A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: parsing xml based on group ID

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    996

    parsing xml based on group ID

    I'm trying to parse xml into a dictionary based on a group id.

    Actionscript Code:
    var dic:Dictionary = new Dictionary();

    var xml:XML = <data>
                <item group="group a">item 1 from group a</item>
                <item group="group b">item 1 from group b</item>
                <item group="group a">item 2 from group a</item>
                <item group="group a">item 3 from group a</item>
                <item group="group a">item 4 from group a</item>
                <item group="group b">item 2 from group b</item>
            </data>
           
    for each ( var item:XML in xml.item ) {
        trace("item = "+item.@group);
    }

    the above is just dummy xml. The group ID could be anything. So I can't do if item.@group is == to "group a" and elseif and so on. Any ideas on how I could make it as dynamic as possible but still be able to access each group through a dictionary.

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    996
    I tried using the sorton which sorted them into an array but its still not what I need. I really want a way to have each group in a dictionary.

    Actionscript Code:
    for each ( var item:XML in xml.item ) {
        //trace("item = "+item.@group);
        var object:Object = {group:item.@group};
        dataArray.push(object);
    }

    dataArray.sortOn("group");

    I'm thinking there is no way around this without keeping the group ID similar like I have above in group a | group b | and so on. Or is it possible??

    Anyone know how I can go about this?
    Last edited by ericflash; 08-24-2010 at 01:38 AM.

  3. #3
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    seems like this is AS3? (Dictionary class)

    maybe posting in the AS3 forum would help get you better results..

    Im not experienced with the dictionary class, so Im not sure what it is you are even trying to do as an end goal.


    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center