02 php生成xml数据

<?php

class Response_xml{


  /**
  *按xml方式输出通信
  *@param integet $code 状态码
  *@param string $message 提示信息
  *@param array $data 数据
  * return string
  */
    public static function xml(){
       header("Content-Type:text/xml");
       $xml ="<?xml version='1.0' encoding='UTF-8'?>\n";
       $xml.="<root>\n";
       $xml.="  <code>200</code>\n";
       $xml.="  <message>返回数据成功</message>\n";
       $xml.="  <data>\n";
       $xml.="     <id>1</id>\n";
       $xml.="     <name>id</name>\n";
       $xml.="  </data>\n";
       $xml.="</root>\n";

       echo $xml;
       die;
    }
}
Response_xml::xml();

 

posted @ 2015-03-20 15:09  麦田守望者~  阅读(125)  评论(0编辑  收藏  举报