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

The Archive Base Latest Questions

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

I am new to iphone development.I am parsing an XML page and displaying the

  • 0

I am new to iphone development.I am parsing an XML page and displaying the content in a tableview.In some block in the XML page , the child element is missing , i want to add a value o in my array, when the child element is not fond in the particular block.My XML file is like

 <entry>
 <id>xxx </id>
 <title>xxxxx</title>
 <gd:ratings numRaters="2"/>
 </entry> ..................................>first block
 <entry>
 <id>xxx </id>
 <title>xxxxx</title>
 </entry> ....................................>Second block
 <entry>
 <id>xxx </id>
 <title>xxxxx</title>
 <gd:ratings numRaters="2"/>
 </entry> .....................................>Third block

I am parsing the gd:ratings tag and display its attribute numRates value in a tableview. I am having an mutable array which stores the value of numRates.I have to add object “O” in the array when the second block is parsed because it doesnot contain gd:ratings tag.Since the value is present in a attribute tag, for retrieving the content and adding it to the mutable array is done in NSXML parser DidStartElement method.

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

currentElement = [elementName copy];
if ([elementName isEqualToString:@"entry"]) {

    entry = [[NSMutableDictionary alloc] init];
    currentTitle = [[NSMutableString alloc] init];
    currentDate = [[NSMutableString alloc] init];
    NSLog(@"inside image1 ");
}else if([elementName isEqualToString:@"media:thumbnail"])
    { currentImage = [[NSMutableString alloc] init];
        if(myUrl == nil){   
        myUrl = [NSString stringWithString:[attributeDict objectForKey:@"url"]];
        }
        [currentImage appendString:myUrl];  
        [stories1 addObject:currentImage];
        myUrl=nil;
        }   else if([elementName isEqualToString:@"gd:rating"])
{
    currentRating=[[NSMutableString alloc]init];

        myRatings=[NSString stringWithString:[attributeDict objectForKey:@"numRaters"]];

    [currentRating appendString:myRatings];
    [stories2 addObject:currentRating];
}   
}

Since there are 25 blocks of entry tags and in that 10 block doesnot have gd rating element .So the array stories2 array has only 15 values.So i cannot display it in the tableview in order.Is there any way out to retrieve the attribute tag in “found characters” method . 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-13T16:51:12+00:00Added an answer on May 13, 2026 at 4:51 pm

    You can use the didEndElement method: when the outer element ended, check if the child element was added to the array.

    You could use an iVar BOOL entryHasRating and do the following:

    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{            
    
       currentElement = [elementName copy];
       if ([elementName isEqualToString:@"entry"]) {
         entryHasRating = NO;
         ...
       } else if ([elementName isEqualToString:@"gd:rating"]){
         entryHasRating = YES;
         ...
       }
    }
    

    Then when an element ends:

    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
       if ([elementName isEqualToString:@"entry"]&& !entryHasRating) {
           [stories2 addObject:@"No Rating"];
           entryHasRating = YES; 
       }
       ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to iphone development.I am parsing a xml page .The xml page
I am new to iphone development.I want parse an you-tube XML page and retrieve
I am new to iphone development.I am parsing a xml file and displaying the
I am new to iphone development.I am parsing a xml file and displaying the
I am new to iPhone development. I am parsing a XML URL and display
I am new to iPhone/Objective-C development, I am successfully parsing XML with NSXMLParser but
Im new to iphone development.I have a tableview controller i want to show selected(multiple)
I am quite new to the iphone development, I am using xml parsing to
I am new to iphone development.I want to ignore CDATA tag while parsing because
I'm new to iPhone development. I want to pass some string with additional SMS

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.