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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:03:36+00:00 2026-05-28T16:03:36+00:00

I have xml data that is retrieved from a server and I need to

  • 0

I have xml data that is retrieved from a server and I need to remove some parts of it in order to set up my tableview. I am converting this data to an NSDictionary, but I think it might be easier to parse (is that the right word?) the xml data rather than messing with it once it’s already converted. Here’s a sample of the xml data.

 <?xml version="1.0" encoding="UTF-8"?>
 <response status="ok">
 <rosters records_per_page="50" page_count="1" page="1" total_record_count="11">
 <roster class_id="685343" role="T" user_id="968428" roster_id="16257539">
 <class name="Haiku API Keys" shortname="haiku_api" end_date="2011-12-20" code=""      
 import_id="" id="685343" description="" teacher_id="971456" year="2012" 
 organization_id="134146" active="false"/>
 </roster>
 <roster class_id="512296" role="S" user_id="968428" roster_id="10456326">
 <class name="Physics AP" shortname="physics-ap_0406-01" end_date="2012-05-02" 
 code="PHYSICSA_0406-01" import_id="0406-01-2012" id="512296" description="DESCRIPTION" 
 teacher_id="968968" year="2012" organization_id="134148" active="true"/>
 </roster>

What I want to do is remove the data that has the object “false” for the key “active.” This would leave me the data with the class name of Physics AP. Is this possible to do with xml data or should I try to remove this data once it is an NSDictionary? This is what the converted NSDictionary looks like.

 (
 {
response =     {
    "@status" = ok;
    rosters =         {
        "@page" = 1;
        "@page_count" = 1;
        "@records_per_page" = 50;
        "@total_record_count" = 11;
        roster =             (
                            {
                "@class_id" = 685343;
                "@role" = T;
                "@roster_id" = 16257539;
                "@user_id" = 968428;
                class =                     {
                    "@active" = false;
                    "@code" = "";
                    "@description" = "";
                    "@end_date" = "2011-12-20";
                    "@id" = 685343;
                    "@import_id" = "";
                    "@name" = "Haiku API Keys";
                    "@organization_id" = 134146;
                    "@shortname" = "haiku_api";
                    "@teacher_id" = 971456;
                    "@year" = 2012;
                };
            },
                            {
                "@class_id" = 512296;
                "@role" = S;
                "@roster_id" = 10456326;
                "@user_id" = 968428;
                class =                     {
                    "@active" = true;
                    "@code" = "PHYSICSA_0406-01";
                    "@description" = "DESCRIPTION";
                    "@end_date" = "2012-05-02";
                    "@id" = 512296;
                    "@import_id" = "0406-01-2012";
                    "@name" = "Physics AP";
                    "@organization_id" = 134148;
                    "@shortname" = "physics-ap_0406-01";
                    "@teacher_id" = 968968;
                    "@year" = 2012;
                };
            },
            }

Just the way the xml data is formatted makes me think it would be easier to accomplish by parsing it, but I don’t know if it is possible, or what method to use. If you have a way to accomplish this by using the xml data or the NSDictionary I would love to hear it. Thanks for your help.

  • 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-28T16:03:37+00:00Added an answer on May 28, 2026 at 4:03 pm

    I use the same XMLReader you’ve used, and I like it.

    If I were to solve the problem, here’s my solution, after you’ve got the dictionary you just need to create a new array of dictionary, to be specific a new array of roster, like this:

    NSArray *roster = [[[theDictionary objectForKey:@"response"] objectForKey:@"rosters"] objectForKey:@"roster"];
    
    NSMutableArray *newRoster = [[NSMutableArray alloc] init];
    
    for(int i=0;i<[roster count];i++){
        NSDictionary *aRoster = [roster objectAtIndex:i];
        //filter the array and add it to the mutable array
        if([[[aRoster objectForKey:@"class"] objectForKey:@"@@active"] isEqualToString:@"true"])
        {
            //this way we only add those data whose active is "true"
            [newRoster addObject:aRoster];
        }
    }
    
    //do what you want with the new roster
    NSLog(@"newRoster = %@",newRoster);
    

    In this case im just assuming you only going to use the the array of “roster” tags and you want to remove those tags whose “active” attributes is equal to string “false”.

    Don’t forget to release the newRoster when you are done with it.

    The XMLReader is quite tedious to work with when it comes to attributes, correct me if I have some errors since i dont have a mac to use today

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

Sidebar

Related Questions

I have some XML data retrieved from a web service that I use to
I have a AJAX post method that gets xml data from server. But when
I have a file which is an XML representation of some data that is
I have a PHP script on a server that generates the XML data on
I have a Grails app that loads its data from xml files and delivers
I have create a simple grid that retrieves data from a server through php.
I have three SQL Server databases that a single application retrieves data from. I
Our company have a need to set up some solution, that would allow us
I have a website that needs to pull information from two diffferent XML data
I have a httpservice that returns xml data. <mx:HTTPService id=httpService url=data/Software.xml resultFormat=e4x result=httpResult_handler(event) fault=Alert.show('XML

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.