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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:25:50+00:00 2026-05-24T16:25:50+00:00

I’ve got an xml file which i’m struggling to traverse through. I’ll let you

  • 0

I’ve got an xml file which i’m struggling to traverse through. I’ll let you know from the off i’m new to xcode. I tried following another guide on here:

iPhone TBXML Looping And Parsing Data but for some reason it doesn’t seem to work for me.

Here’s my XML File:

<Locations action="Request" version="1.0">
     <location>
       <CompanyID>44502</CompanyID>
       <CompanyName>Holiday Inn</CompanyName>
       <Distance>3.58km/2.23miles</Distance>
         <tabs>
           <tab>General Information</tab>
           <tab>Add Review</tab>
         </tabs>
       <Address>
           <Address1>Holiday Inn Reading - South</Address1>
           <Address2>500 Basingstoke Road</Address2>
           <Address3/>
           <PostTown>Reading</PostTown>
           <County/>
           <PostCode>RG2 0SL</PostCode>
       </Address>
     </location>
</Locations>

I’m trying to traverse through this with TBXML to grab each of the items (I managed to do it with one, but couldn’t loop through).

The .h file is:

@interface LoadXML : UIViewController {

    IBOutlet UITableView *tblLoadXML;
    NSMutableArray *records; 
    }
@property(nonatomic,retain)NSMutableArray *records;

-(void)loadRecords:(NSString *)records;
-(void)traverseElement:(TBXMLElement *)element;

@end

However I’m getting 2 errors on that saying: `Expected a type and Expected ‘)’ before TBXMLElement.

My .M file has the following:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (Cell == nil) {
        Cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }


    Cell.text = [records objectAtIndex:indexPath.row];

}

- (void)loadRecords:(NSString *)records {
    NSString *someXML = @"http://de0937/directenquirieswebapplicationv3.0/mobilesearch/what/0/49424/342/0/Reading/Hotels%20and%20Inns/0/0/0/0/0/search.aspx";
    TBXML *tbxml = [[TBXML tbxmlWithURL:[NSURL URLWithString:someXML]] retain];

    records = [NSMutableArray array];
    [records retain];

    if (tbxml.rootXMLElement)
        [self traverseElement:tbxml.rootXMLElement];
    [tbxml release];
}

- (void) traverseElement:(TBXMLElement *)element {
    do {
        if (element->firstChild) 
            [self traverseElement:element->firstChild];

        if ([[TBXML elementName:element] isEqualToString:@"location"]) {
            TBXMLElement *name = [TBXML childElementNamed:@"CompanyName" parentElement:element];
            TBXMLElement *distance = [TBXML childElementNamed:@"Distance" parentElement:element];

            TBXMLElement *id = [TBXML childElementNamed:@"ID" parentElement:element];

            [records addObject:[NSArray arrayWithObjects:
                                [TBXML textForElement:name],
                                [TBXML textForElement:distance],
                                [TBXML textForElement:id],nil]];  
        }
    } while ((element = element->nextSibling));  
}

I’m probably doing something very stupid, but it’s driving me insane! Any help will be much appreciated.

— This is what I had before, and it works perfectly but only for one record. Basically what i’m trying to do is convert this so I can put each item as an array and pull it out at will:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *Cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (Cell == nil) {
        Cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }


    TBXML * XML = [[TBXML tbxmlWithURL:[NSURL URLWithString:@"http://www.tomstest.info/ios/results.xml"]] retain];

    TBXMLElement *rootXML = XML.rootXMLElement;
    TBXMLElement *results = [TBXML childElementNamed:@"location" parentElement:rootXML];  
    TBXMLElement *WOEID = [TBXML childElementNamed:@"CompanyName" parentElement:results]; 
    NSString *woeid = [TBXML textForElement:WOEID];


    Cell.text = woeid;
    return Cell;

}
  • 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-05-24T16:25:51+00:00Added an answer on May 24, 2026 at 4:25 pm

    Based on the error, are you #including TBXML.h from the .h file? Alternatively, you could @class TBXMLElement; in the .h file and an import in the .m file.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm parsing an XML file, the creators of it stuck in a bunch social
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.