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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:59:02+00:00 2026-05-20T15:59:02+00:00

hi all im parsing an xml file and saving in a nsmutabledictionary and while

  • 0

hi all im parsing an xml file and saving in a nsmutabledictionary and while retriving its giving duplicate values.

 <CalculateCSResult>

        <Message>Hi This is the calculated info</Message>

        <Custodial>

          <Income>22</Income>

          <OverNights>12</OverNights>

          <ExemptionAmount>425</ExemptionAmount>

          <StandardDeduction>512</StandardDeduction>

          <FedTaxableIncome>8569</FedTaxableIncome>

          <FederalTax>245</FederalTax>

          <StateTax>451</StateTax>

          <FICA>451</FICA>

          <NetIncome>652</NetIncome>

          <NetIncomePct>412542</NetIncomePct>

        </Custodial>

        <NonCustodial>

          <Income>842</Income>

          <OverNights>652</OverNights>

          <ExemptionAmount>356</ExemptionAmount>

          <StandardDeduction>541</StandardDeduction>

          <FedTaxableIncome>658</FedTaxableIncome>

          <FederalTax>412</FederalTax>

          <StateTax>142</StateTax>

          <FICA>652</FICA>

          <NetIncome>696</NetIncome>

          <NetIncomePct>96896</NetIncomePct>

        </NonCustodial>

        <TaxYear>523</TaxYear>

        <ChilsSupportAmt>652</ChilsSupportAmt>

        <CutodialChildTaxCredit>652</CutodialChildTaxCredit>

        <Alerts>xmlxml</Alerts>

      </CalculateCSResult>


#import "ResultParser.h"

@implementation ResultParser

@synthesize calcResult; 
NSMutableDictionary *tempDict;

-(void)parse:(NSURL *)url {
    NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
    tempDict = [[NSMutableDictionary alloc]init];
    [xmlParser setDelegate:self];
    if(![xmlParser parse])
        NSLog(@"Error Error Error!!!");
}

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
    attributes:(NSDictionary *)attributeDict {

    if ([elementName isEqualToString:@"CalculateCSResult"]) {
        calcResult = [[NSMutableDictionary alloc] init];
    } 

} 

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {   
    if(!currentElementValue) 
        currentElementValue = [[NSMutableString alloc] initWithString:string];
    else
        [currentElementValue appendString:string];
}

- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {

    if([elementName isEqualToString:@"CalculateCSResult"]) {
        return;
    }else if([elementName isEqualToString:@"Message"]) {
        [calcResult setObject:currentElementValue forKey:elementName];
    }else if([elementName isEqualToString:@"Income"] ||
        [elementName isEqualToString:@"OverNights"] || 
             [elementName isEqualToString:@"ExemptionAmount"] ||
             [elementName isEqualToString:@"StandardDeduction"] ||
             [elementName isEqualToString:@"FedTaxableIncome"] ||
             [elementName isEqualToString:@"FederalTax"] || 
             [elementName isEqualToString:@"StateTax"] || 
             [elementName isEqualToString:@"FICA"] || 
             [elementName isEqualToString:@"NetIncome"] ||
             [elementName isEqualToString:@"NetIncomePct"]) {
        [tempDict setObject:currentElementValue forKey:elementName];
    }else if([elementName isEqualToString:@"NonCustodial"] || [elementName isEqualToString:@"Custodial"]) {
        [calcResult setObject:tempDict forKey:elementName];
        [tempDict removeAllObjects];
    }else if([elementName isEqualToString:@"TaxYear"]) {
        [calcResult setObject:currentElementValue forKey:elementName];
    }else if([elementName isEqualToString:@"ChilsSupportAmt"]) {
        [calcResult setObject:currentElementValue forKey:elementName];
    }else if([elementName isEqualToString:@"CutodialChildTaxCredit"]) {
        [calcResult setObject:currentElementValue forKey:elementName];
    }else if([elementName isEqualToString:@"Alerts"]) {
        [calcResult setObject:currentElementValue forKey:elementName];
    }

    [currentElementValue release];
    currentElementValue = nil;      
}

- (void)dealloc {
    [tempDict release];
    [calcResult release];
    [super dealloc];
}

@end

and after parsing and im saving the calcResult dictionary in resDict in another class and displaying as below.

NSLog(@" message = %@",[resDict objectForKey:@"Message"]);
    NSMutableDictionary *custDict =(NSMutableDictionary *)[resDict objectForKey:@"Custodial"];
    NSLog(@" Income = %@",[custDict objectForKey:@"Income"]);
    NSLog(@" OverNights = %@",[custDict objectForKey:@"OverNights"]);
    NSLog(@" ExemptionAmount = %@",[custDict objectForKey:@"ExemptionAmount"]);
    NSLog(@" StandardDeduction = %@",[custDict objectForKey:@"StandardDeduction"]);
    NSLog(@" FedTaxableIncome = %@",[custDict objectForKey:@"FedTaxableIncome"]);
    NSLog(@" FederalTax = %@",[custDict objectForKey:@"FederalTax"]);
    NSLog(@" StateTax = %@",[custDict objectForKey:@"StateTax"]);
    NSLog(@" FICA = %@",[custDict objectForKey:@"FICA"]);
    NSLog(@" NetIncome = %@",[custDict objectForKey:@"NetIncome"]);
    NSLog(@" NetIncomePct = %@",[custDict objectForKey:@"NetIncomePct"]);
    NSMutableDictionary *ncustDict =(NSMutableDictionary *)[resDict objectForKey:@"NonCustodial"];
    NSLog(@" Income = %@",[ncustDict objectForKey:@"Income"]);
    NSLog(@" OverNights = %@",[ncustDict objectForKey:@"OverNights"]);
    NSLog(@" ExemptionAmount = %@",[ncustDict objectForKey:@"ExemptionAmount"]);
    NSLog(@" StandardDeduction = %@",[ncustDict objectForKey:@"StandardDeduction"]);
    NSLog(@" FedTaxableIncome = %@",[ncustDict objectForKey:@"FedTaxableIncome"]);
    NSLog(@" FederalTax = %@",[ncustDict objectForKey:@"FederalTax"]);
    NSLog(@" StateTax = %@",[ncustDict objectForKey:@"StateTax"]);
    NSLog(@" FICA = %@",[ncustDict objectForKey:@"FICA"]);
    NSLog(@" NetIncome = %@",[ncustDict objectForKey:@"NetIncome"]);
    NSLog(@" NetIncomePct = %@",[ncustDict objectForKey:@"NetIncomePct"]);
    NSLog(@" TaxYear = %@",[resDict objectForKey:@"TaxYear"]);
    NSLog(@" ChilsSupportAmt = %@",[resDict objectForKey:@"ChilsSupportAmt"]);
    NSLog(@" CutodialChildTaxCredit = %@",[resDict objectForKey:@"CutodialChildTaxCredit"]);
    NSLog(@" Alerts = %@",[resDict objectForKey:@"Alerts"]);

the problem is its not displaying the Custodial details… for both Custodial and NonCustodial is displaying NonCustodilal data…

please help me out

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-20T15:59:02+00:00Added an answer on May 20, 2026 at 3:59 pm

    The problem is that the objects in an NSDictionary are shallow-copied, which is to say that after you add tempDict to calcResult, it simply contains a pointer to tempDict. This is not true for the keys in the dictionary though, which are copied and cannot be modified later without affecting the integrity of the dictionary.

    Also, I’d like to point out that you can dump the entire contents of your dictionaries using NSLog(@“resDict = %@“, resDict); and similar.

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

Sidebar

Related Questions

Hi at all I want to parsing a date from XML with this format:
Hey all i am new to XML parsing on VB.net. This is the code
I have xml file in server. I am parsing this xml using DOM(xml is
I followed a quick tutorial on parsing an XML file, this what i have.
I am parsing xml file data from an url. All works great when device
Background: I am parsing a 330 meg xml file into a DB (netflix catalog)
Before this question gets stamped as a duplicate, I am sorry! I've read ALL
I am parsing an xml file successfully in PHP, but having difficulty parsing a
Here is my code: (source: http://www.androidhive.info/2011/11/android-xml-parsing-tutorial/ ) Here is my XML file: removed On
I am parsing XML using jQuery. I want to get the count of all

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.