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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:58:12+00:00 2026-05-26T15:58:12+00:00

I know my xml looking very much odd but nothing to do. Now my

  • 0

I know my xml looking very much odd but nothing to do. Now my problem is how can I parse this xml attribute and its value using TBXML?

−<order>
 <id>100</id>
  <order_date>October 13th, 2011 at 2:43 PM</order_date>
 −<customer>
   <id>45</id>
   <name>John Kramer</name>
   −<address>
     −<billing>167 Yarra Street, South Yarra, Melbourne, Australia</billing>
     −<shipping>35 Victoria, Street, North Yarra, Melbourne, Australia</shipping>
      <email> johnkramer@hotmail.com</email>
      <phone> +6546325478 </phone>
     </address>
   </customer>
  −<products>
    −<product>
    <id>12</id>
    <name>Asus F5RL</name>
   −<description>Color: Blue. Size: Square.</description>
    <qty>2</qty>
    <unit_price>50 AUD</unit_price>
    <total_price>100 AUD</total_price>
   </product>
  −<product>
   <id>12</id>
   <name>Acer F4</name>
   <description>Color: Red</description>
   <qty>3</qty>
   <unit_price>40 AUD</unit_price>
   <total_price>120 AUD</total_price>
  </product>
 </products>

 -<price_details>
    <subtotal>220 AUD</subtotal>
    <discount>20 AUD</discount>
    <tax> 10 AUD </tax>
    <shipment> 5 AUD </shipment>
    <grand_total> 235 AUD </grand_total>
  </price_details>
 <order_status>Pending </order_status>
</order>

still now I have done this but it is crashing.

- (void)traverseElement:(TBXMLElement *)element {
do {
    NSLog(@"%@",[TBXML elementName:element]);
    if (element->firstChild) 
        [self traverseElement:element->firstChild];


    TBXMLAttribute * attribute = element->firstAttribute;

    // if attribute is valid
    while (attribute) {
        // Display name and value of attribute to the log window
        NSLog(@"%@->%@ = %@",
              [TBXML elementName:element],
              [TBXML attributeName:attribute],
              [TBXML attributeValue:attribute]);

        // Obtain the next attribute
        attribute = attribute->next;
    }

    if ([[TBXML elementName:element] isEqualToString:@"order"]) {
        NSLog(@"xml element checking");
        TBXMLElement *order_id = [TBXML childElementNamed:@"id" parentElement:element];
        TBXMLElement *order_date = [TBXML childElementNamed:@"order_date" parentElement:element];
        TBXMLElement *customer = [TBXML childElementNamed:@"customer" parentElement:element];

        TBXMLElement *customer_id = [TBXML childElementNamed:@"id" parentElement:customer];
        TBXMLElement *customer_name = [TBXML childElementNamed:@"name" parentElement:customer];
        [records addObject:[NSArray arrayWithObjects:
                            [TBXML textForElement:customer_id],
                            [TBXML textForElement:customer_name],
                            [TBXML textForElement:order_id],
                            [TBXML textForElement:order_date],nil ] ];
        NSLog(@"customer id: %@",customer_id);
        NSLog(@"customer name: %@",customer_name);
    }   
  • 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-26T15:58:13+00:00Added an answer on May 26, 2026 at 3:58 pm

    I have solve this problem may be it will helpful for someone…

    - (void)traverseElement:(TBXMLElement *)element {
    do {
        NSLog(@"%@",[TBXML elementName:element]);
        if (element->firstChild) 
            [self traverseElement:element->firstChild];
    
    
        TBXMLAttribute * attribute = element->firstAttribute;
    
        // if attribute is valid
        while (attribute) {
            // Display name and value of attribute to the log window
            NSLog(@"%@->%@ = %@",
                  [TBXML elementName:element],
                  [TBXML attributeName:attribute],
                  [TBXML attributeValue:attribute]);
    
            // Obtain the next attribute
            attribute = attribute->next;
        }
    
        if ([[TBXML elementName:element] isEqualToString:@"order"]) {
            NSLog(@"xml element checking");
            TBXMLElement *order_id = [TBXML childElementNamed:@"id" parentElement:element];
            TBXMLElement *order_date = [TBXML childElementNamed:@"order_date" parentElement:element];
            TBXMLElement *order_customer = [TBXML childElementNamed:@"customer" parentElement:element];
            NSLog(@"order id: %@ %@ %@",[TBXML textForElement:order_id],[TBXML textForElement:order_date],[TBXML textForElement:order_customer]);
            if([[TBXML elementName:order_customer] isEqualToString:@"customer"]){
                TBXMLElement *customer_id = [TBXML childElementNamed:@"id" parentElement:order_customer];
                TBXMLElement *customer_name = [TBXML childElementNamed:@"name" parentElement:order_customer];
                TBXMLElement *customer_address = [TBXML childElementNamed:@"address" parentElement:order_customer];
                NSLog(@"order id: %@ %@ %@",[TBXML textForElement:customer_id],[TBXML textForElement:customer_name],[TBXML textForElement:customer_address]);
                if([[TBXML elementName:customer_address] isEqualToString:@"address"]){
                    TBXMLElement *address_billing = [TBXML childElementNamed:@"billing" parentElement:customer_address];
                    [records addObject:[NSArray arrayWithObjects:
                                        [TBXML textForElement:order_id],
                                        [TBXML textForElement:order_date],
                                        [TBXML textForElement:customer_id],
                                        [TBXML textForElement:customer_name],
                                        [TBXML textForElement:address_billing],nil]];
                }
            }
    
          //  TBXMLElement *order_status = [TBXML childElementNamed:@"status" parentElement:element];
    
            //NSLog(@"%@",[TBXML textForElement:id]);
            // NSArray *newArray = [[NSArray alloc] init];
    
        }
        [myTable reloadData];
    } while ((element = element->nextSibling));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can add service behaviors with some XML configuration, but I'd like
I know we can request xml, html as well as text images directly using
I know I can retrieve some settings.xml parameters using properties, like, for example ${settings.localRepository}
I know you can do bulk XML inserts into SQL Server 2005 tables from
Anybody know how to produce an xml element like this in rails using xml
Currently I am trying something very simple. I am looking through an XML document
(This post is soliciting personal experiences about storing XML; please share what you know.
To begin with, I know very little about DTSX files and SSIS, but my
I'm looking into a system where users can upload xml files to a website
I know this is a probable open ended question, and I have tried looking

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.