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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:53:12+00:00 2026-06-13T03:53:12+00:00

I have to parse two XML files in a singleview and so I m

  • 0

I have to parse two XML files in a singleview and so I m using two NSXMLParsers to get it.But he proble m is one parser is getting recognized and second parser is not getting recognized…I mean after the debugger passes this line [parser1 parse] it should go to the delegates didStartElement,foundcharacters and didEndElement but in my case the debugger is not entering those delegates.It is simply jumping to [parser1 release] stmnt.So those delegates are not getting recognized for parser1.Y is it so ?
I have written this :

 NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:Url];      
 [parser setDelegate:self];
 [parser setShouldProcessNamespaces:NO];
 [parser setShouldReportNamespacePrefixes:NO];
 [parser setShouldResolveExternalEntities:NO];
 [parser parse];
 [parser release];

  NSXMLParser *parser1 = [[NSXMLParser alloc] initWithContentsOfURL:Url1];      
[parser1 setDelegate:self];
[parser1 setShouldProcessNamespaces:NO];
[parser1 setShouldReportNamespacePrefixes:NO];
[parser1 setShouldResolveExternalEntities:NO];
[parser1 parse];
[parser1 release];


 - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{
  if([elementName isEqualToString:@"TimeList"])
 {
 arr1=[[NSMutableArray alloc] init];
 drr1=[[NSMutableDictionary alloc] init];

 }
 if([elementName isEqualToString:@"Company"])
 { 
 drr1=[[NSMutableDictionary alloc] init];        
 }
 srr1=[[NSMutableString alloc] init];

 } 


 -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{


 [srr1 appendString:string];
 }


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

 if([elementName isEqualToString:@"ID"])
 {

 [drr1 setObject:srr1 forKey:@"ID"];
 [srr1 release],srr1=nil;
 return;
 }  

 if([elementName isEqualToString:@"Company"]) 
 { 
 [arr1 addObject:drr1]; 
 }    


 if([elementName isEqualToString:@"TimeList"])
 {

[drr1 release];

 }

  [srr1 release],srr1=nil; 
 }




- (void)parser1:(NSXMLParser *)parser1 didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{
    if([elementName isEqualToString:@"categorylist"])
    {
        arr2=[[NSMutableArray alloc] init];
        drr2=[[NSMutableDictionary alloc] init];

    }
    if([elementName isEqualToString:@"lookup"])
    { 
        drr2=[[NSMutableDictionary alloc] init];        
    }
    srr2=[[NSMutableString alloc] init];

} 


-(void)parser1:(NSXMLParser *)parser1 foundCharacters:(NSString *)string{


    [srr2 appendString:string];
}


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

    if([elementName isEqualToString:@"Code"])
    {

        [drr2 setObject:srr2 forKey:@"Code"];
        [srr2 release],srr2=nil;
        return;
    }  

    if([elementName isEqualToString:@"lookup"]) 
    { 
        [arr2 addObject:drr2]; 
    }    


    if([elementName isEqualToString:@"categorylist"])
    {

        [drr2 release];

    }

    [srr2 release],srr2=nil; 
    }

The first parser is getting recognized and getting the data.But for the second parser didStartElement is not getting recognized…What could be the possible reason ?

  • 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-13T03:53:13+00:00Added an answer on June 13, 2026 at 3:53 am

    I solved it by myself.Actually I declared a string and passed some value to it.While parsing it checks ,if that condition gets true then it parses ..
    This is what I did:

    NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:Url];      
    [parser setDelegate:self];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    currentparser=@"1";
    [parser parse];
    [parser release];
    
      NSXMLParser *parser = [[NSXMLParser alloc] initWithContentsOfURL:Url1];      
    [parser setDelegate:self];
    [parser setShouldProcessNamespaces:NO];
    [parser setShouldReportNamespacePrefixes:NO];
    [parser setShouldResolveExternalEntities:NO];
    currentparser=@"2";
    [parser parse];
    [parser release];
    
     - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
     {
     if(currentparser==@"1")
     {
         //do something
     } 
     if(currentparser=@"2")
     {
         //do something
      }
      }
    
     -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    
    
       if(currentparser==@"1")
         {
            //do something
         }
       if(currentparser=@"2")
        {
           //do something
        }
        }
    
    
        - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
    
       if(currentparser==@"1")
        { 
         //do something
        }
        if(currentparser=@"2")
        {
          //do something
         }
         }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In My iphone application i have two XML files. I can parse one.xml eailsy
I want to parse a large XML file and I have two options: Perl
I have got an application, that is getting data via XML-files. During the parsing-part
I need to parse xml files from two sources. Both xml files contain the
I have two large XML files(c.100MB) containing a number of items. I want to
I have a server configured to receive XML files via POST, parse them, and
I have to compare XML data. There are two sources- Web Service XML files
I have some .xml files that are encoded in UTF-8 . But whenever I
I have made one application which can parse the given xml file independent of
I have to validate two SAML 2.0 assertion signatures. I can parse out 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.