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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:45:01+00:00 2026-05-27T23:45:01+00:00

after a HTTP Post I retrieve an xml response like the following: <result value=OK>

  • 0

after a HTTP Post I retrieve an xml response like the following:

<result value="OK">
    <user id="1">
            <name>admin</name>
            <rank>0</rank>
            <picture_count>0</picture_count>
            <comment_count>0</comment_count>
            <has_profile>1</has_profile>
    </user>
</result>

I’d like to extract the user ID, but I don’t know how to do this.
I tried with GDataXML Parser, because this is already integrated in my project, but
I don’t know how to get a value inside a html tag.

I hope you can help me. If there is no solution with XMLParser, would you recommend regular expressions? In this case, I would appreciate a solution for the regex expression, I’m not very good at this 🙂

Thanks in advance.

  • 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-27T23:45:02+00:00Added an answer on May 27, 2026 at 11:45 pm

    This is the code I use to retrieve the user attribute. It works.

    NSString* path = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"xml"];
    
    NSData *xmlData = [[NSMutableData alloc] initWithContentsOfFile:path];
    NSError *error;
    GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:xmlData 
                                                               options:0 error:&error];
    
    NSArray *userElements = [doc.rootElement elementsForName:@"user"];
    
    for (GDataXMLElement *userEl in userElements) {
    
        // Attribute
        NSString *attribute = [(GDataXMLElement *) [userEl attributeForName:@"id"] stringValue];        
        NSLog(@"attribute for user is %@", attribute);
    
        // Name
        NSArray *names = [userEl elementsForName:@"name"];
        if (names.count > 0) {
            GDataXMLElement *name = (GDataXMLElement *) [names objectAtIndex:0];
    
            NSLog(@"name for user is %@", name.stringValue);
        }
    
        // Rank
        NSArray *ranks = [userEl elementsForName:@"rank"];
        if (ranks.count > 0) {
            GDataXMLElement *rank = (GDataXMLElement *) [ranks objectAtIndex:0];
    
            NSLog(@"rank for user is %@", rank.stringValue);
        }
    
        // Do the same for other tags...     
    }
    
    [doc release];
    [xmlData release];
    

    The file test.xml is the same that you retrieve from the xml response. So you need to change the second line of this snippet of code. Maybe you can call initWithData method of class NSData.

    You can put this code where you want. Maybe you can create an other class that works as a centralized parser. Hope it helps

    EDIT

    Put these two lines before for instruction.

    NSString *valAttribute = [(GDataXMLElement *) [doc.rootElement attributeForName:@"value"] stringValue];        
    NSLog(@"value attribute for result is %@", valAttribute);
    

    The explanation is quite simple. With doc.rootElement you retrieve the entire xml document, from <result> to </result>

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

Sidebar

Related Questions

When I call Response.Redirect(someUrl) I get the following HttpException: Cannot redirect after HTTP headers
I like the pattern I saw in this blog post ( http://marekblotny.blogspot.com/2009/04/conventions-after-rewrite.html ), where
After Jeph most recent post: http://www.codinghorror.com/blog/archives/001310.html , I thought to myself it would be
I am building a Httphandler following these instructions here It manipulates HTTP POST and
After creating a new ASP.NET Web Service I want it only to support HTTP-POST
I'm making a HTTP Post and I would like to know how to convert
After reading http://www.w3schools.com/tags/tag_noscript.asp confused about onclick event on noscript tag. Anybody knows the purpose?
After reading http://www.pragprog.com/magazines/2010-03/javascript-its-not-just-for-browsers-any-more I'm wondering which is the best IDE to develop server-side javascript
After reading this: http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-to-use-it I came to the conclusion that it is not valid
I made an image to easier explain what Im after: Image Illustration http://bayimg.com/image/eabahaaci.jpg Ive

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.