【问题标题】:i am geting data from server using xml parsing in android我正在使用 android 中的 xml 解析从服务器获取数据
【发布时间】:2012-05-16 23:12:46
【问题描述】:

我想使用 xml 解析从服务器获取数据,我将我的 php 代码用于返回 xml 输出,但是如何使用 url 运行这个 php 函数并显示我的 xmloutput xml格式

我的php服务在这里

<?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;
}   
}   

【问题讨论】:

    标签: php android web-services xml-parsing


    【解决方案1】:

    这里有两个部分。

    基于 PHP 的服务器端系统如何公开以 XML 格式显示信息的 WEB-SERVICE。 一旦你实现了,你应该通过 rest-client 或直接在浏览器的地址栏中运行链接。如果它显示 xml,那么它工作得很好。

    对于 android,它就像点击一个 URL 并从连接输入流中读取它的输入。 我们通常将其传递给解析器(例如 SAX 解析器、DOM 解析器等)。在应用程序中进一步使用。

    两者的示例都可以很容易地在 Google 上搜索到。

    SAX 解析器的一个好方法是 http://java-samples.com/showtutorial.php?tutorialid=152

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-06
      • 2010-10-11
      • 1970-01-01
      • 2020-10-30
      • 1970-01-01
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多