开发者

iOS: Reading Data out of a xml, generated via php-script into objective-c

i have a php script which connects to a MySQL-Database and generates a XML. The XML holds the Data which i select from the Database. My Question now is how to start the php script and then get the data out of the php script generated XML.

I got no idea how to do this, maybe you can help me.

PHP-Script:

// DB Connect

$connection = mysql_connect($server, $user, $password);
mysql_select_db($dbName, $connection);
$result = mysql_query($query);
mysql_close ($connection);


// XML Output

header ("Content-Type:text/xml");
?>
<?xml version="1.0" encoding="UTF-8"?>
<?php
echo '<standing version="1.0">';
while ($row = mysql_fetch_assoc($result)){
    echo '<'.$row['object_id'].'>
      <term_taxonomy>'.$row['taxonomy'].'</term_taxonomy>
      <description&开发者_StackOverflow中文版gt;'.$row['description'].'</description>
      <post_date>'.$row['post_date_gmt'].'</post_date>
      <post_content>'.$row['post_content'].'</post_content>
      <post_title>'.$row['post_title'].'</pst_title>
      <post_exerpt>'.$row['post_exerpt'].'</post_exerpt>
    </'.$row['object_id'].'>';
}
echo '</standing>';
?>

Maybe you have any code snippets or tutorials how to do this!

Thanks a lot, you would save my Live!!!


You have to make your script available through a URL and then call it within your app. Check out the documentation for NSURL, NSURLConnection and NSXMLParser. Just retrieve your data from the URL and then parse it with the XML parser. Here is a tutorial on parsing. Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜