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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:59:21+00:00 2026-05-30T12:59:21+00:00

Possible Duplicate: iPhone Development – XMLParser vs. libxml2 vs. TouchXML How can I parse

  • 0

Possible Duplicate:
iPhone Development – XMLParser vs. libxml2 vs. TouchXML

How can I parse the below response to get the data elements like Id, RegionId, and CountryName? Please help me to solve the problem in iPhone.

<feed xml:base="http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Countries</title>
  <id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries</id>
  <updated>2012-02-27T10:55:19Z</updated>
  <link rel="self" title="Countries" href="Countries" />
  <entry>
    <id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(14)</id>
    <title type="text"></title>
    <updated>2012-02-27T10:55:19Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Country" href="Countries(14)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" type="application/atom+xml;type=entry" title="Region" href="Countries(14)/Region" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Contact_Country" type="application/atom+xml;type=feed" title="Contact_Country" href="Countries(14)/Contact_Country" />
    <category term="HpSalesPortalMobileDBModel.Country" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Id m:type="Edm.Int16">14</d:Id>
        <d:RegionId m:type="Edm.Byte">1</d:RegionId>
        <d:CountryName>France</d:CountryName>
      </m:properties>
    </content>
  </entry>
  <entry>
    <id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(15)</id>
    <title type="text"></title>
    <updated>2012-02-27T10:55:19Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Country" href="Countries(15)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" type="application/atom+xml;type=entry" title="Region" href="Countries(15)/Region" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Contact_Country" type="application/atom+xml;type=feed" title="Contact_Country" href="Countries(15)/Contact_Country" />
    <category term="HpSalesPortalMobileDBModel.Country" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
    <content type="application/xml">
      <m:properties>
        <d:Id m:type="Edm.Int16">15</d:Id>
        <d:RegionId m:type="Edm.Byte">1</d:RegionId>
2012-02-27 16:25:18.933 SampleTest[571:f803] >>>>>>>>>>  Route data <?xml version="1.0" encoding="utf-8" standalone="yes"?>
<feed xml:base="http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <title type="text">Countries</title>
  <id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries</id>
  <updated>2012-02-27T10:55:19Z</updated>
  <link rel="self" title="Countries" href="Countries" />
  <entry>
    <id>http://infra2appsmobile.cloudapp.net/Infra2Apps.svc/Countries(14)</id>
    <title type="text"></title>
    <updated>2012-02-27T10:55:19Z</updated>
    <author>
      <name />
    </author>
    <link rel="edit" title="Country" href="Countries(14)" />
    <link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Region" type="application/atom+xml;type=entry" title="Region" href="Countries(14)/Region" />
    <link rel="h

hi martin i have use your code like below but i unable to parsing the data i mean can’t able to parse the specific data like id, RegionId and Countryname also it is not entering into the for(){}.
give me the solution for how to parse the data.

NSArray *array=[thexml componentsSeparatedByString:@””];
NSLog(@”%d”,[array count]);
NSLog(@”————->>>>>>>>>>>23344<<<<<<<<<———%d”,[array count]);
// NSString *str1=[array objectAtIndex:0];
//
// NSArray *array1=[str1 componentsSeparatedByString:@””];
// NSLog(@”%d”,[array1 count]);
for(int i=1;i<[array count];i++)
{
NSLog(@”————->>>>>>>———%d”,[array count]);

        NSString *str=[array objectAtIndex:i];
        NSLog(@"------------->>>>>>>>><<<<<<<<<---------%@",str);
        NSArray *arr1=[str componentsSeparatedByString:@"<text>"];
        NSLog(@"------------->>>>>>>>>>>1111<<<<<<<<<---------%@",arr1);

        NSString *data=[arr1 objectAtIndex:1];
        NSRange ranfrom=[data rangeOfString:@"</text>"];
        // nt.truckName=[data substringToIndex:ranfrom.location];
        [tweets  addObject:[data substringToIndex:ranfrom.location]];
        NSLog(@"------------->>>>>>>>>>>2222<<<<<<<<<---------%@",tweets);
    }

2012-02-28 13:38:38.609 SampleTest[358:f803] ————->>>>>>>><<<<<<<<<———1

  • 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-30T12:59:22+00:00Added an answer on May 30, 2026 at 12:59 pm

    Well I parse xml some different way than others and being frank I really do not know which technique it is but I assure you it works fine for me and I have implemeted it successfully in so many projects. Have a look at my code where I load tweets from some profile

    This is the function where I make call for parser.

    -(void)loadtweet
    {
    @try
    {
        NSString *urlString = [NSString stringWithFormat:@"https://api.twitter.com/1/statuses/user_timeline.xml?screen_name=SrBachchan&count=5"];
    
        NSLog(@"fetching data from--------> : %@",urlString);
    
        NSString* escapedUrlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
    
        NSMutableURLRequest *request1 = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:escapedUrlString]];
    
        NSURLConnection *con=[[NSURLConnection alloc]  initWithRequest:request1 delegate:self];
        if(con)
            truckData=[[NSMutableData data]retain];
    }
    
    @catch (NSException *exception) 
    {
        UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"Please Try Again Later." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [v show];
        [v release];
    }
    
    }
    

    And these are the NSURLConnection delegate methods:

    - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
    {
    [truckData setLength:0];
    }
    
    - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data 
    {
    [truckData appendData:data];
    }
    
    - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
    {
    
    }
    
    - (void)connectionDidFinishLoading:(NSURLConnection *)connection 
    
    {
       [tweets removeAllObjects];
     @try 
    {
        // [app.trucks removeAllObjects];
        NSString *thexml=[[NSString alloc] initWithBytes:[truckData mutableBytes] length:[truckData length] encoding:NSUTF8StringEncoding];
    
        NSArray *array=[thexml componentsSeparatedByString:@"<status>"];
        NSLog(@"%d",[array count]);
    
        for(int i=1;i<[array count];i++)
        {
            NSString *str=[array objectAtIndex:i];
            NSArray *arr1=[str componentsSeparatedByString:@"<text>"];
            NSString *data=[arr1 objectAtIndex:1];
            NSRange ranfrom=[data rangeOfString:@"</text>"];
            // nt.truckName=[data substringToIndex:ranfrom.location];
            [tweets  addObject:[data substringToIndex:ranfrom.location]];
        }
    }
    
    @catch (NSException *exception) 
    {
        UIAlertView *v = [[UIAlertView alloc] initWithTitle:@"ERROR" message:@"Please Try Again Later." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [v show];
        [v release];
     }
    
    }
    

    I have used some string functions to separate tags and stored the values in Array.

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

Sidebar

Related Questions

Possible Duplicate: How can I develop for iPhone using a Windows development machine? Basically,
Possible Duplicate: How can I develop for iPhone using a Windows development machine? Does
Possible Duplicate: Parsing XML in Cocoa iPhone - Can we parse .plist(xml) file using
Possible Duplicate: How can I develop for iPhone using a Windows development machine? I've
Possible Duplicate: Starting iPhone app development in Linux? Is there a way to use
Possible Duplicate: iPhone apps for company-internal use - possible? As a developer, I can
Possible Duplicate: iPhone development on Windows I am android developer. Now In our Company
Possible Duplicate: iPhone development on Windows Obviously i don't have a Mac machine. But
Possible Duplicate: iPod touch for iPhone development Is the new Ipod Touch 3G support
Possible Duplicate: iPhone development on Windows Is it possible to create iPhone apps using

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.