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

  • Home
  • SEARCH
  • 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 8410643
In Process

The Archive Base Latest Questions

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

Here is a simple XML: <MSG> <ID>123<ID> <Node> <ID>456<ID> </Node> </MSG> And I got

  • 0

Here is a simple XML:

<MSG>
    <ID>123<ID>
    <Node>
       <ID>456<ID>
    </Node>
</MSG>

And I got a parser which is subclass of ParentParser and implements NSXMLParserDelegate

The ParentParser is something like this:

- (id)initWithXmlString:(NSString *)xmlString
{
    if ( (self = [super init]) ) {
        NSString *str = [[NSString alloc] initWithString:xmlString];
        self.xml = str;
        [str release];

        self.storingData     = NO;
        self.receiveString   = [NSMutableString string];
        self.elementsToParse = [NSArray array];
    }

    return self;
}

And this is how I parse the XML:

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

   if (self.m_oMyObject) {
      if (self.storingData) {
         NSString *tempStr = [self.receiveString stringByTrimmingCharactersInSet:
                              [NSCharacterSet whitespaceAndNewlineCharacterSet]];
         [self.receiveString setString:@""];

         if ([elementName isEqualToString:kID]) {
             //Go in twice
         }
     //============ Code skips ===================

As you can see, the kID, String ID had been parse twice. But I would like to have the 123 only, not the 456, which is inside the <Node> tag, how can I fix it? 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-06-10T00:13:55+00:00Added an answer on June 10, 2026 at 12:13 am

    I don’t think that you can make NSXMLParser skip nested elements, but you could keep track of the current level by incrementing an instance variable level in parser:didStartElement:... and decrementing it in parser:didEndElement:....

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

Sidebar

Related Questions

I've got some simple XML-handling code that's supposed to locate a child node of
I've created a simple xml file here: http://roberthan.host56.com/productsNew.xml which is quite simple, the root
I have a simple XML file here which I converted to XSD with xsd.exe
Consider this simple XML document. The serialized XML shown here is the result of
Here is a simple form I am using to send XML data in admin_xml.php
Hi i've got here a simple program, but it's not working properly. When i
I have to be missing something simple here but it escapes me. After the
I think i must be missing something simple here but I can't figure out
Here is simple xml android animation: <translate xmlns:android=http://schemas.android.com/apk/res/android android:fromXDelta=0 android:fromYDelta=0 android:toXDelta=-110 android:toYDelta=-110 android:duration=1000 android:fillAfter=true
I am doing a simple XML parser program.I am running it in command prompt.The

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.