本帖最后由 weijiepeng 于 2009-11-12 14:19:24 编辑

解决方案 »

  1.   

    百度 google bing soso youdao gougou sogou
      

  2.   

    具体需求是 http方式  将一些数据返回xml给对方 首先 得将数据库的数据取出来后,转成xml,
     
      

  3.   

    http://www.ibm.com/developerworks/cn/opensource/os-xmldomphp/
      

  4.   

    如果数据量不是很大的话,可以将数据存成数组,然后再将数组转成xml.
    当然也可以循环取出再利用domxml等生成xml
      

  5.   

    我还是喜欢用字符串操作。
    xml也就是一段字符串罢了。做字符串替换然后输出最简单了。echo "<root><title>".$title."</title></root>";
      

  6.   

    存成数组转化xml
    e4x法解析
      

  7.   

    /**
    数组$result 是读取的数据表的内容,代码略。
    **/
    $dom = new DOMDocument('1.0','utf-8');
    $dom->formatOutput =true;
    $rootnode = $dom->appendChild($dom->createElement('rows'));foreach ($result as $row)
    {
    $rownode = $rootnode->appendChild($dom->createElement('row'));
    $rownode->setAttribute('id',$row['id']);
    foreach ($row as $cell)
    {
    $cellnode = $rownode->appendChild($dom->createElement('cell'));
    $txtnode = $cellnode->appendChild($dom->createCDATASection($cell));
    }
    }
    echo $dom->saveXML();
      

  8.   

    在程序开头加上
    if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
    header("Content-type: application/xhtml+xml;charset=utf-8");
    } else {
    header("Content-type: text/xml;charset=utf-8");
    }
      

  9.   

    就是生成  xml 好了写个 函数不就OK了