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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:39:13+00:00 2026-05-27T18:39:13+00:00

I am developing an iPhone app and I want to put some datas to

  • 0

I am developing an iPhone app and I want to put some datas to UITableView.
I got an app showing several xml parser run from here.

and then, I’d separated GDataXMLParser from this project and made it run but
I have an odd problem that I can’t figure out.

This is the code putting php file.

- (void)start {
    self.startTimeReference = [NSDate timeIntervalSinceReferenceDate];
    [[NSURLCache sharedURLCache] removeAllCachedResponses];
    self.parsedSongs = [NSMutableArray array];
    NSURL *url = [NSURL URLWithString:@"http://mydomain.blabla/phpxmltest.php"];
    [NSThread detachNewThreadSelector:@selector(downloadAndParse:) toTarget:self withObject:url];
}

When I make a php to xml with echo directly, like this way,

......
echo "<entry><title>this is the TEST</title><item>TEST</item></entry>";
......

iPhone app does parse this code like XML.
But when I make a php to xml with mySQL query (cause I want to make a xml items from DB), like this way,

<?php
echo '<?xml version="1.0" encoding="UTF-8"?>';
$result = mysql_connect("localhost", "my ID", "my Password");
mysql_select_db("my DB");
$q = "select name, price, age, likeit, keyword from Table where category=101";
$result = mysql_query($q);
$num_rows = mysql_num_rows($result);

echo "<entry>\n";
for ($i=1; $i<=$num_rows; $i++) {
    $row = mysql_fetch_assoc($result);
    echo "<item>\n";
    echo "<title>" . $row["name"] . "</title>\n";
    echo "<category>" . $row["price"] . "</category>\n";
    echo "<artist>" . $row["age"] . "</artist>\n";
    echo "<album>" . $row["likeit"] . "</album>\n";
    echo "<releasedate>" . $row["keyword"] . "</releasedate>\n";
    echo "</item>\n";
}
echo "</entry>";
?>

iPhone app doesn’t parse this code. It tells me there’s no item in XML.
What is the most strange to me, is the results on Web Browser are same exactly.
When I put the url in browser, the output itself and the source(with viewing source function of browser) are exactly same. This is the source view in web browser.(Plz don’t mind some encoding problem)

<?xml version="1.0" encoding="UTF-8"?>
<entry>
<item>
<title>������ ���ĺ� ������</title>
<category>11000</category>
<artist>3</artist>
<album>0</album>
<releasedate>���ĺ� ���߱�</releasedate>
</item>
<item>
<title>���ĺ� ��������</title>
<category>18000</category>
<artist>3</artist>
<album>0</album>
<releasedate>���ĺ� ����</releasedate>
</item>
…..

I’ve tried hard to make it work but it’s too difficult for me. I am a starter in iOS and Web Programming. Please let me know what is the problem and solution.
Thank u in advance!:D

  • 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-27T18:39:13+00:00Added an answer on May 27, 2026 at 6:39 pm

    (Plz don’t mind some encoding problem)

    Maybe we don’t mind but the xml parser probably does.
    You should

    • set the mimetype in the http response header
    • set the charset in the http response header (though it’s already in the xml declaration)
    • set mysql’s client encondig to utf8 in order to receive the data utf-8 encoded
    • treat all the data from the database with an appropriate escape function
    • or even better use something like XMLWriter

    and you should also print error messages as a somewhat valid xml document since you told the client that it will receive xml.

    E.g. (tested only by php -l):

    <?php
    if ( headers_sent() ) {
      die("can't set mimetype and/or charset after output has been sent to the client");
    }
    ini_set('default_charset', 'utf-8');
    ini_set('default_mimetype', 'text/xml');
    // ini_set('default_mimetype', 'application/xml');
    
    echo '<?xml version="1.0" encoding="UTF-8"?>';
    
    $mysql = mysql_connect("localhost", "my ID", "my Password");
    if ( !$mysql ) {
        die('<error>database connection failed</error>');
    }
    
    if ( !mysql_select_db("my DB", $mysql) ) {
        die('<error>database selection failed</error>');
    }
    
    if ( !mysql_set_charset('utf8', $mysql) ) {
        die('<error>setting database selectiocharset failed</error>');
    }
    
    $q = 'SELECT name, price, age, likeit, keyword FROM Table WHERE category=101';
    $result = mysql_query($q, $mysql);
    if ( !$result ) {
        die('<error>database query failed</error>');
    }
    
    
    echo "<entry>\n";
    while( false!=($row=mysql_fetch_assoc($result)) ) {
        echo '
            <item>
                <title>',  htmlspecialchars($row["name"], 'utf-8'), '</title>
                <category>', htmlspecialchars($row["price"], 'utf-8'), '</category>
                <artist>', htmlspecialchars($row["age"], 'utf-8'), '</artist>
                <album>', htmlspecialchars($row["likeit"], 'utf-8'), '"</album>
                <releasedate>',  htmlspecialchars($row["keyword"], 'utf-8'), '</releasedate>
            </item>';
    }
    echo "</entry>";
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iPhone app. I've got a function that reads data from a
If I'm developing an iPhone app for CompanyX and when we want to put
I am developing an iPhone app that displays several views, all acessed via Tab
guys. I'm developing iphone app. so, I want to read database of iphone calendar.
I am developing on iPhone app, Where i want to capture the other applications
I'm developing an iPhone app. In a label, I want to show an user's
I'm developing a first iPhone app for iOS 4.x/5.0 and have some confusions on
I'm developing an iPhone app that switches from a table view to a landscape
So i've been spending some time developing an iPhone app - it's a simple
I am developing an iPhone app where I don’t want/need the multitasking capability and

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.