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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:15:13+00:00 2026-06-11T18:15:13+00:00

I am sending a query to a server and getting response using this code

  • 0

I am sending a query to a server and getting response using this code

 NSString *urlString = @"myPHPQuery";
 NSURL *parserUrl = [[[NSURL alloc] initWithString:urlString] autorelease];
        NSXMLParser *parser = [[[NSXMLParser alloc] initWithContentsOfURL:parserUrl] autorelease];
        [parser setDelegate:self];
        [parser parse]; 

I can get this type of response

<users>
                            <username>nothan</username>
                            <score>1000</score>                         
                            </users>
<users>
                            <username>nothan</username>
                            <score>1000</score>                         
                            </users>

I am using this code to parse the data in Mutable Array

int arrayCount = 0;

NSString *elementname;
NSInteger * count;

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict 
{    
    elementname = elementName;
}

-(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{

    if([elementname isEqualToString:@"username"])
    {
        if ( count == 0 )
        { 
            NSLog(@"%@" , string);
            [self.playerNames replaceObjectAtIndex:arrayCount withObject:string];
            arrayCount = arrayCount + 1;
            count = count + 1 ;
        }
        else
            count = 0;

    }
    else if([elementname isEqualToString:@"score"])
    {
        if ( count == 0 )
        {
            NSLog(@"%@" , string);

            [self.scores replaceObjectAtIndex:arrayCount withObject:string];
            count = count + 1 ;
        }
        else
            count = 0; 
    }
}

- (void)parserDidEndDocument:(NSXMLParser *)parser 
{

    for (int i = 0 ; i <10 ; i++)
    {
        NSLog(@"%d - %@" , i,[playerNames objectAtIndex:i]);
    }
}

The problem with this code is, it retrieve only one

<users> .... </users> How can I change this code to make it retrieve more users.

Best Regards

  • 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-06-11T18:15:15+00:00Added an answer on June 11, 2026 at 6:15 pm

    For the sample XML you posted above, the parser ran correctly.

    Extensible Markup Language (XML) 1.0 (Fifth Edition) §2.1 Well-Formed XML Documents

    There is exactly one element, called the root, or document element

    After the first <users>…</users> element is parsed, the document has finished and the parser stops.

    To have a list if things in an XML document, you must wrap them in an outer element.

    <allusers>
      <users>
        <username>nothan</username>
        <score>1000</score>                         
      </users>
      <users>
        <username>nothan</username>
        <score>1000</score>                         
      </users>
    </allusers>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sending XML from C# Server and receiving it it in Android Java client This
when sending data to a php server through android I cam across this error:
I am sending post request from android to the url using httpclient like this
I'm using this query to get all employees of {clients with name starting with
sending mail along with embedded image using asp.net I have already used following but
Sending Email in Android using JavaMail API without using the default/built-in app I'm trying
Im sending (with ASIFormDataRequest) a POST request, with 4 parameters. The server launches a
I sending ajax request from a jQuery file like below, which expects response in
When sending uncontrolled amounts of TextWebSocketFrames to a simple Netty WebSocket echo server implementation
I'm using socket to establish a streaming connection with server. By creating a socket,

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.