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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:25:32+00:00 2026-06-01T23:25:32+00:00

I have the following xml. I am trying to parse this using gdataxml parser.

  • 0

I have the following xml. I am trying to parse this using gdataxml parser. I am able to parse the first part of the xml, <myBean> to </myBean>, but from the second part, from <trackBean>, it s becoming harder as the trackBean is recursing inside. I am finding it hard to develop a logic for that. I am stuck here for the 2nd day.

 <return>
   <myTrackBean>
    <myBean>
                <myStatus>false</myStatus>
                <hisStatus>false</hisStatus>
                 <secondVcardBean>
                     <contactId>108</contactId>                         
                     <myNumber>KXUOYHGCIO</myNumber>
                     <userId>56</userId>
                     <version>1</version>                         
                </secondVcardBean>
                <myNumber>KXUOYHGCIO</myNumber>
            </myBean>
            <trackBean>
               <myBean>
                  <myStatus>false</myStatus>
                  <hisStatus>false</hisStatus>
                  <secondVcardBean>
                     <contactId>105</contactId>
                     <myNumber>5D1X7XP6CW</myNumber>
                     <userId>54</userId>
                     <version>1</version>
                 </secondVcardBean>
                 <myNumber>5D1X7XP6CW</myNumber>
             </myBean>
             <trackBean>
                <myBean>
                     <myStatus>false</myStatus>
                     <hisStatus>false</hisStatus>
                     <secondVcardBean>
                         <contactId>103</contactId>
                         <myNumber>0C3RM5UKBB</myNumber>
                         <userId>53</userId>
                         <version>8</version>
                     </secondVcardBean>
                    <myNumber>0C3RM5UKBB</myNumber>
                </myBean>
          </trackBean>
      </trackBean>
  </myTrackBean>
</return>

The following is the code I have used for parsing the first part, from the first <myBean> to <myBean>. How can I check whether a <trackBean> exists inside its parent <trackBean>

NSArray * array = [node nodesForXPath:@"//return/myTrackBean" error:nil];

            int noOfmyTrackBean = [array count];

            for(int i = 1; i<= noOfmyTrackBean; i++){


                NSString *tempXmlData = [NSString stringWithFormat:@"//return/myTrackBean/myBean"];

                NSString *myStatus = [node nodeStringForXPath:[tempXmlData stringByAppendingString:@"/myStatus"]];

                NSString *hisStatus = [node nodeStringForXPath:[tempXmlData stringByAppendingString:@"/hisStatus"]];

                NSString *contactId = [node nodeStringForXPath:[tempXmlData stringByAppendingString:@"/secondVcardBean/contactId"]];

                NSString *myNumber = [node nodeStringForXPath:[tempXmlData stringByAppendingString:@"/secondVcardBean/myNumber"]];

I understand that the difficulty is in getting the <trackBean> child node inside <trackBean>

  • 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-01T23:25:34+00:00Added an answer on June 1, 2026 at 11:25 pm

    I think you dont need to worry a lot about recursion, as gdataxml seems to handle that part internally. You can just parse it normally as the parser object takes the count of the nodes that repeats inside itself. I dont know if its exactly what to you need, but it will definitely help you.

    NSArray * array = [node nodesForXPath:@"//return/myTrackBean" error:nil];
                NSLog(@"count  :%d",[array count]);
                NSLog(@"Node  :%@",node);
    
                int noOfPrimaryNodes = [array count];
    
                for(int i = 1; i<= noOfPrimaryNodes; i++){
    
                    //For use from the second node
                    NSString *myxmlData = [NSString stringWithFormat:@"//return/myTrackBean/trackBean"];
                    NSLog(@"myxmlData  :%@",myxmlData);
    
    
                    NSArray *array = [node nodesForXPath:@"//return/myTrackBean/trackBean" error:nil];
    
                    NSLog(@"Array count %d", [array count]);
                    if([array count]>0){
                    GDataXMLElement *myNode = [[node nodesForXPath:@"//return/myTrackBean/trackBean" error:&error]objectAtIndex:0];
                     NSLog(@"myNode  :%@",myNode);
    
    
    
                    NSString *changingNode = @"//trackBean";
    
    
                    for(int j = 0; j < [array count]; j++){
    
                        NSString *myStatus = [node nodeStringForXPath:[changingNode stringByAppendingString:@"/myBean/myStatus"]];
                        NSString * hisStatus = [node nodeStringForXPath:[changingNode stringByAppendingString:@"/myBean/hisStatus"]];
                        NSString *contactId = [node nodeStringForXPath:[changingNode stringByAppendingString:@"/myBean/secondVcardBean/contactId"]];
                        NSString *myNumber = [node nodeStringForXPath:[changingNode stringByAppendingString:@"/myBean/secondVcardBean/myNumber"]];
                        NSString *versionNumber = [node nodeStringForXPath:[changingNode stringByAppendingString:@"/myBean/secondVcardBean/versionNumber"]];
             }
    

    Hope this would help.

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

Sidebar

Related Questions

I'm trying to parse xml from SharePoint service (lists) using jquery. I have XMLHttpRequest
Trying to use JSTL but have the following problem: Index.xhtml page: <?xml version=1.0 encoding=UTF-8?>
I have been using this code to parse xml till now. Its was working
I am trying to parse data from a xml web service but I am
I have the following XML: <XMLDictionary> <a>b</a> <c>d</c> <e>f</e> </XMLDictionary> I'm trying to get
If i have the following directory structure: Project1/bin/debug Project2/xml/file.xml I am trying to refer
I am new to jquery. I am trying to parse xml string using jquery.
Currently I am trying to parse an xml string that I already have (no
I am trying to get familiar with using the XDocument API to parse XML
I'm trying to extract some data from XML using Linq to XML, and I

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.