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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:23:56+00:00 2026-06-14T03:23:56+00:00

i am creating an app that shows the latest feeds from a particular webservice,i

  • 0

i am creating an app that shows the latest feeds from a particular webservice,i am using NSXMLParserDelegate protocol for this purpose,well i read the apple documentation and i tried some tutorials too,but something seems to be going wrong somewhere,i dont understand how does the didEndElement,foundCharacters work,anyways i want to display the image,title and content,pub-date of the post,i am newbie to xmlparsing here’s my viewcontroller.h(i have just parsed only the title element in the following code)

   @property(nonatomic,strong)NSString *currentElement;
   @property(nonatomic,strong)NSString *currentTitle;
   @property(nonatomic,strong)NSMutableArray *titles;

viewdidload

NSURL *url=[NSURL URLWithString:@"http://www.forbes.com/fast/feed"];
NSXMLParser *parser=[[NSXMLParser alloc]initWithContentsOfURL:url];
[parser setDelegate:self];
[parser parse];
NSLog(@"%d",titles.count);

didStartElement

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

self.currentElement=elementName;

if ([self.currentElement isEqualToString:@"title"]) 
{

    self.currentTitle=[NSMutableString alloc];
    titles=[[NSMutableArray alloc]init];

    titles=[attributeDict objectForKey:@"title"];
}
 }

foundCharacters

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

self.currentElement=elementName;

if ([self.currentElement isEqualToString:@"title"]) 
{

    self.currentTitle=[NSMutableString alloc];
    titles=[[NSMutableArray alloc]init];

    titles=[attributeDict objectForKey:@"title"];
}
  }

didEndElement

 -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if([self.currentElement isEqualToString:@"title"])
{
    NSLog(@"%@",self.currentTitle);


}
}

doubts

1)where am i supposed to declare my titles array so that i can add individual title object to it.
what is the use of [attributeDict objectForKey] in didStartElement? it returned null for my program

2)what does foundCharacters delegate actually do? what does it append?

3)After didEndElement why doesnt the compiler reach for didStartElement and not the foundCharacters ?

4)finally should i actually use NSXMLParserDelegate protocol for the xml parsing,do others like touchXML,TBXML and others provided in the raywenderlich make a difference?

i am sorry for the long post,but i havent got any satisfying answers online regarding my queries,i used all the breakpoints and figured out how the delegates are called back and forth,i need some enlightening answers to my queries,thanks and sorry

  • 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-06-14T03:23:57+00:00Added an answer on June 14, 2026 at 3:23 am

    1. Declare your array before starting to parse.Whenever you meet an elements (an xml tag), initialize the elements (set some BOOL in the class in a way that you can recognize what element you are reading);

    2. Found characters are the characters found as value of a tag.If you know what element you are reading (reading your instance variables), you should append this string to your temporary NSMutableString and add it to the array only when the element is ended.

    3. Because it doesn’t start finding other characters until a new tag is reached.

    Example

    I see that you are confused, let’s say that you have this XML code:

    <person> mickey mouse </person>
    

    When you meet the tag the element starts, then you find other characters (not the entire string, just a part of the string) until the string ends, then when you meet the tag the element is ended.

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

Sidebar

Related Questions

I am programming for iPhone, creating an app that shows various locally stored HTML
I'm creating an iPhone app that shows a large number of pins on a
I found a great tutorial on creating an MVC App from Scratch using Sencha
I want to create a app that shows data from a local db in
I am creating a web app using ASP.NET MVC, which shows some articles to
I'm creating an Android app that displays tv-shows on a listview. My shows coming
I'm creating an SL4 app that needs to query certain data via a webservice
I am creating an app MainActivity that can calculate a report from its database
What I'm doing: I'm creating a sample app that shows how to incorporate Kendo
I am creating an app that will point a simple arrow in the direction

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.