简体   繁体   中英

i am geting data from server using xml parsing in android

i want to get the data from server using xml parsing here i put my php code for return xml output but how can i run this php function using url and is display my xmloutput in xml format

my php service is here

<?php

include('configuration.php');
include('i_connection.php');


if(function_exists($_GET['f']))
{
    $_GET['f']();

    function getdata($xml_output)
    {   
   $result = mysql_query("SELECT state FROM `pic_upload`");
   $xml_output .="<photo>";

   while($row = mysql_fetch_array($result)) 
   {        
                $xml_output .="<photos>";

                if($result['state'] != "")
                $xml_output .="<State>".$result['state']."</State>";
                else
                $xml_output .="<State></State>";

                $xml_output .="</photos>";
    }
     $xml_output .="</photo>";
  return $xml_output;
}   
}   

Two parts are there in this.

How PHP based server side system exposing WEB-SERVICE that displays the information in XML. Once you implement that you should run the link via rest-client or directly in address bar of the browser. if it displays the xml then its working great.

For android its just like hitting a URL and reading its input from the Connection Input Stream. Which we generally passes to the Parsers (eg SAX Parser, DOM Parser etc). Which is futher used in the application.

Sample example of both can be easily googled.

Good one for SAX Parser is http://java-samples.com/showtutorial.php?tutorialid=152

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM