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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T14:22:37+00:00 2026-06-03T14:22:37+00:00

iam developing one application.In that iam using the xml parsing.That xml file contain the

  • 0

iam developing one application.In that iam using the xml parsing.That xml file contain the 4 category tags and other tags.From the xml file i want to get the data of category tag.At the time of getting the category data,every time i print the array of category values.That show correctly.But after completion of parsing, another tag data will be append to last category name.My parsing code is like below.

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if(self.presentvalue)
{
    [presentvalue appendString:string];
}
}
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
{

if(![elementName compare:@"category"])
{
    [categories addObject:presentvalue];
    NSLog(@"%@",presentvalue);
    NSLog(@"Number of elements %@",categories);
}

}
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if([elementName isEqualToString:@"category"])
{
    presentvalue=[NSMutableString string];  
}
}

And my xml file content is like

    <lesson>
   <categories>
   <category id="1">1</category>
   <category id="2">2</category>
   <category id="3">3</category>
   </categories>
   <references>
    <reference id="1" type="youtube" categoryid="2" name="Boyles law">
    <url><![CDATA[http://www.youtube.com/watch?v=J_I8Y-i4Axc]]>
     </url>
    </reference>
    </references>
    </lesson>

From this xml i got the array values like 1,2,3http://www.youtube.com/watch?v=J_I8Y-i4Axc.Like this i got the result.So please tell me how to get the category values without that extra data.

  • 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-03T14:22:38+00:00Added an answer on June 3, 2026 at 2:22 pm
    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
    {
    if ([elementName isEqualToString:@"category"]) {
        NSLog(@"Node is found correctly");
        if(presentvalue == nil)
            presentvalue = [NSMutableString string];
        else 
            [presentvalue setString:@""];
    }
    else {
        presentvalue = nil;
    }
    
    }
    
    
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
    {
    
    [presentvalue appendString:string];
    if (presentvalue) 
    {
       [self.tempArray addObject:presentvalue]; // add this line. create a tempArray containing all the strings.
        presentvalue = nil;
    }
    }
    

    this should help u in your parsing. hope it helps. happy coding 🙂

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

Sidebar

Related Questions

Iam developing one application.In that i take the string from array and replace .xml
I am developing one application. In that iam using the NSMutableArray for storing the
I am developing one application.In that iam using the progress view.In this i need
I am developing one web application. In that i want to use variable's value
I am developing one application that requires records from Addressbook , I need all
I am developing one console application using perl script. In that I am printing
I am developing one application. In that I want to post a tweet on
Iam developing one applciation.In that application i used the both imageview and textview.And iam
I am developing one application. In that I want to record the sounds and
I am developing one web application in that I want to check load time

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.