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

  • Home
  • SEARCH
  • 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 8798601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:07:57+00:00 2026-06-14T00:07:57+00:00

I have been trying to fill an array in Xcode with xml output from

  • 0

I have been trying to fill an array in Xcode with xml output from a php script so that ios can connect to mysql. However, I keep getting an empty value for my array despite the fact that there is information in mysql. That must mean that either my attribute section or my parsing of the xml is wrong, but I really don’t know what it is that actually is wrong (and no amount of starring at it seems to help). I am not getting any errors from php or xcode. Any ideas?

EDIT: I have followed the suggestions below and I am still getting an empty value, although I believe that it is coming from my php…

- (void)viewDidLoad
{
    [super viewDidLoad];

    char *cStr = "YES";
    NSString *str3 = [NSString stringWithUTF8String:cStr];


    NSString *urlString = [NSString stringWithFormat:@"(censored)", _login];

    NSXMLParser *Parser = [[[NSXMLParser alloc] initWithContentsOfURL:[NSURL URLWithString:urlString]] autorelease];
    [Parser setDelegate:self];
    [Parser parse];


NSDictionary *itemAtIndex =(NSDictionary *)[oneam objectAtIndex:0];
  oneam = [[NSMutableArray alloc] init];   
    if (([[itemAtIndex objectForKey:@"its"]isEqualToString:str3 ])) {
            [switch1 setOn:YES animated:YES];
    }
    else {
            [switch1 setOn:NO animated:YES];
    }

}

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

    if ( [elementName isEqualToString:@"location"]) {
        [oneam addObject:[[NSDictionary alloc] initWithDictionary:attributeDict]];
    NSLog(@"The array is %@", oneam);
    }
}

And here is my php…

<?php

$login = "hello";
$dbh = new PDO('(censored)');
$sql = "SELECT oneam FROM login WHERE username = '$login'";

$q = $dbh->prepare( $sql );

$doc = new DOMDocument();
$r = $doc->createElement( "oneam" );
$doc->appendChild( $r );
foreach ( $q->fetchAll() as $row) {
    $e = $doc->createElement( "location" );

    $e->setAttribute( 'its', $row['oneam']);

    $r->appendChild( $e );

}
print $doc->saveXML();
?>
  • 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-14T00:07:59+00:00Added an answer on June 14, 2026 at 12:07 am

    I don’t know if you maybe have them somewhere else, but you’re missing 2 methods I’ve always used when doing .xml parsing: foundCharacters and didEndElement. I followed this tutorial set (all 3 videos – about 40 min worth), and after using it on a couple different instances it really helped me understand how to use the NSXMLParsers. Maybe try following his methods and see if that clears things up for you.

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

Sidebar

Related Questions

I have been trying to extract data from a database and fill in a
Have been trying to encrypt an xml file to a string so that I
i have been trying to create an xml file that integrates a relative layout
Have have been trying to make a validator for my xml files. I have
I have been trying to create a ListView which I can sort using drag
I have been trying to serialize a list that contains arrays and lists. I
I have been trying to get my EditText box to word wrap, but can't
I have been trying to work out the bug on this but can't seem
I have been trying this for a while now and can't get it to
i have been trying to write a program to insert the array values in

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.