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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:24:07+00:00 2026-05-28T01:24:07+00:00

I have an NSDictionary that was converted from XML that is really confusing me.

  • 0

I have an NSDictionary that was converted from XML that is really confusing me. If you could take a look and let me know the best method of getting the objects for the key class_id, I would really appreciate it.

 {
     response=  {
        "@status" = ok;
        rosters =         {
                     "@page" = 1;
                     "@page_count" = 1;
                     "@records_per_page" = 50;
                     "@total_record_count" = 8;
                     roster =               (
                                            {
                                       "@class_id" = 0001;
                                       "@role" = 0;
                                       "@user_id" = 12345;
                                       class=                  {
                                                                "@active" = false;
                                                                "@name" = NAME;
                                                               }
                                            }
                                            {
                                       "@class_id" = 0002;
                                       "@role" = 0;
                                       "@user_id" = 12345;
                                            }
                                            {
                                       "@class_id" = 0003;
                                       "@role" = 0;
                                       "@user_id" = 12345;
                                            }
                                            );
                             }
                 }
}

All I am wanting to do is either set up variables for the individual class_id’s or put all of the class_id’s in an NSArray. I’ve been reading the apple documentation and have tried every method I can think of, but it either crashes with nsexception or returns no data. Thanks so much for your help.

Ok let’s just backup a minute. It would appear that the XMLReader plugin that I used to convert this to an NSDictionary is making this far more complicated than it needs to be. Here is the original XML data.

<response status="ok">
<rosters page_count="1" page="1" records_per_page="50" total_record_count="7">
<roster class_id="0001" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0002" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0003" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0004" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0005" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0006" role="S" user_id="91563" roster_id="ID"/>
<roster class_id="0007" role="S" user_id="91563" roster_id="ID"/>
</rosters>
</response>

Can anyone suggest a simple way to just grab the class_id values? Is converting to NSDictionary a reasonable way to do it? I just need the data as separate variables or an NSArray.

  • 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-28T01:24:07+00:00Added an answer on May 28, 2026 at 1:24 am

    Don’t worry about the “best method”. Just use a method that won’t be confusing to revisit later and lets you move on to more important things.

    NSMutableArray *classIds = [NSMutableArray array];
    NSDictionary *rosterArray = [convertedXmlDictionary valueForKeyPath:@"response.rosters.roster"];
    for (NSDictionary *roster in rosterArray) {
        [classIds addObject:[roster objectForKey:@"@class_id"]];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSDictionary that contains data converted from json data, like {message_id:21} .
I have xml data that is retrieved from a server and I need to
I have a NSTimer that I create when entering method - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary
I have an XML exported from Oracle DB, which will be downloaded into my
I have this NSDictionary that I want to load into a table view. It
I have an NSDictionary that logs this: address = 30 East 23rd Street; address1
I receive json from a webservice into a NSMutableData. That gets converted into a
Hey guys, I have a Cocoa application that sends an NSDictionary over the network
i have an NSDictionary that contain in value and i need to get this
I have a large NSDictionary that I need to loop through and create separate

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.