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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:08:23+00:00 2026-05-26T08:08:23+00:00

Am trying to parse the below xml using TBXML. I want to create an

  • 0

Am trying to parse the below xml using TBXML. I want to create an array which contains all the item tag values. How can I traverse through the “item” tags?

<root>
<item>
<northeast_area>
<item>
<new_england_north xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[8]">
    <item xsi:type="xsd:string">boston s, ma</item>
    <item xsi:type="xsd:string">providence, ri</item>
    <item xsi:type="xsd:string">boston, ma </item>
    <item xsi:type="xsd:string">portland, me</item>
    <item xsi:type="xsd:string">boston, ma </item>
    <item xsi:type="xsd:string">boston central</item>
    <item xsi:type="xsd:string">boston north, ma</item>
    <item xsi:type="xsd:string">boston south, ma</item>
</new_england_north>
</item>

<item>
<upstate_new_york xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[6]">
    <item xsi:type="xsd:string">binghampton, ny</item>
    <item xsi:type="xsd:string">rochester, ny</item>
    <item xsi:type="xsd:string">albany s, ny</item>
    <item xsi:type="xsd:string">syracuse, ny</item>
    <item xsi:type="xsd:string">albany, ny</item>
    <item xsi:type="xsd:string">buffalo, ny</item>
</upstate_new_york>
</item>
</northeast_area>
</item>

  • 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-26T08:08:23+00:00Added an answer on May 26, 2026 at 8:08 am

    Here’s a piece of sample code that reads the XML from a file. You can tweak it to use an available NSString/NSData object. Note that since we don’t know the exact potential formats that your SOAP calls can return, this isn’t very robust, it’s just a solution that works for the data you’ve provided.

    int main (int argc, const char * argv[])
    {
    
        @autoreleasepool {
            NSString* path = @"/Path/To/Your/File";
            NSData *contents = [[NSFileManager defaultManager] contentsAtPath:path];
            TBXML *xml = [TBXML tbxmlWithXMLData:contents];
    
            TBXMLElement *rootElement = [xml rootXMLElement];
    
            TBXMLElement *rootItemElem = [TBXML childElementNamed:@"item" parentElement:rootElement];
    
            while (rootItemElem != nil) {
                TBXMLElement *areaElement = rootItemElem->firstChild;
    
                while (areaElement != nil) {
                    TBXMLElement *areaItemElement = [TBXML childElementNamed:@"item" parentElement:areaElement];
                    while (areaItemElement != nil) {
                        TBXMLElement *localeItem = areaItemElement->firstChild;
                        NSLog(@"Checking locale %s", localeItem->name);
                        TBXMLElement *specificItem = [TBXML childElementNamed:@"item" parentElement:localeItem];
                        while (specificItem != nil) {
                            NSLog(@"Item with value: %@", [TBXML textForElement:specificItem]);
                            specificItem = [TBXML nextSiblingNamed:@"item" searchFromElement:specificItem];
                        }
    
                        areaItemElement = [TBXML nextSiblingNamed:@"item" searchFromElement:areaItemElement];
                    }
    
                    areaElement = areaElement->nextSibling;
                }
    
                rootItemElem = [TBXML nextSiblingNamed:@"item" searchFromElement:rootItemElem];
            }
    
        }
        return 0;
    }
    

    And the output:

    2011-10-19 08:20:40.321 Testing[14768:707] Checking locale new_england_north
    2011-10-19 08:20:40.323 Testing[14768:707] Item with value: boston s, ma
    2011-10-19 08:20:40.323 Testing[14768:707] Item with value: providence, ri
    2011-10-19 08:20:40.324 Testing[14768:707] Item with value: boston, ma
    2011-10-19 08:20:40.324 Testing[14768:707] Item with value: portland, me
    2011-10-19 08:20:40.325 Testing[14768:707] Item with value: boston, ma
    2011-10-19 08:20:40.326 Testing[14768:707] Item with value: boston central
    2011-10-19 08:20:40.326 Testing[14768:707] Item with value: boston north, ma
    2011-10-19 08:20:40.327 Testing[14768:707] Item with value: boston south, ma
    2011-10-19 08:20:40.327 Testing[14768:707] Checking locale upstate_new_york
    2011-10-19 08:20:40.328 Testing[14768:707] Item with value: binghampton, ny
    2011-10-19 08:20:40.328 Testing[14768:707] Item with value: rochester, ny
    2011-10-19 08:20:40.329 Testing[14768:707] Item with value: albany s, ny
    2011-10-19 08:20:40.329 Testing[14768:707] Item with value: syracuse, ny
    2011-10-19 08:20:40.330 Testing[14768:707] Item with value: albany, ny
    2011-10-19 08:20:40.330 Testing[14768:707] Item with value: buffalo, ny
    

    Using this, it should be fairly straightforward to create an NSArray and store the items, or create an NSArray for each locale and separate the items that way. (Storing them in an NSDictionary keyed by the locale.)

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

Sidebar

Related Questions

I am trying to parse the below xml in sql server to get all
I'm trying to parse out the XML below with the PHP code shown here
I am trying to parse a XML document using Xerces, but I cant seem
I'm trying to parse the XML below so that I wind up with an
I'm trying to parse a moderately large XML file (6mb) in php using simpleXML.
I'm trying to parse some relative large xml-files using the standard sax parser in
I am trying to parse an XML file as below <Subject> <chapter> <Question>abc</Question> <answer>avksn</answer>
I am trying to parse an xml response using jQuery and just output an
I am trying to pass the XML code below, in the first instance using
i am trying to parse an xml element using XMLDocument ( DItem >> Title

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.