下面是请求后返回的数据
如何获取其中的xmlHTTP/1.1 200 OK
Connection: close
Date: Fri, 27 May 2011 02:38:56 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Cache-Control: private, max-age=0
Content-Type: text/xml; charset=utf-8
Content-Length: 457<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SubmitMmsResponse xmlns="http://MmsWebInterface.org/"><SubmitMmsResult><State>0</State><MsgID>110527103856160</MsgID><MsgState>审查</MsgState><Reserve>199702000</Reserve></SubmitMmsResult></SubmitMmsResponse></soap:Body></soap:Envelope>

解决方案 »

  1.   

    假设返回数据的文件为:b.php ,在c.php中获取:
      

  2.   

    LS可以清楚点吗  没太明白  为什么要去c里获取?
      

  3.   

    不好意思,点错了,接着上面:       $con=file_get_contents('b.php');
           preg_match("/<\?xml[^>]+>(.*)<\/soap:Envelope>/is",$con,$arr);
           echo $arr[0]; 
    输出:
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SubmitMmsResponse xmlns="http://MmsWebInterface.org/"><SubmitMmsResult><State& gt;0</State><MsgID>110527103856160< /MsgID><MsgState>审查< /MsgState><Reserve>199702000</Reserve></SubmitMmsResult></SubmitMmsResponse></soap:Body></soap:Envelope>
      

  4.   

     
    $flg=0;$str_xml="";
    while ($line = fgets($fp)) {        if (ereg("^\<\?xml",$line)) {
            $flg=1;
        }
        if($flg){
          $str_xml.=$line;
         }
    }
      

  5.   

    也可以在写在一个文件里:   $str=<<<HTML
    HTTP/1.1 200 OK
    Connection: close
    Date: Fri, 27 May 2011 02:38:56 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    Cache-Control: private, max-age=0
    Content-Type: text/xml; charset=utf-8
    Content-Length: 457<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><SubmitMmsResponse xmlns="http://MmsWebInterface.org/"><SubmitMmsResult><State& gt;0</State><MsgID>110527103856160< /MsgID><MsgState>审查< /MsgState><Reserve>199702000</Reserve></SubmitMmsResult></SubmitMmsResponse></soap:Body></soap:Envelope>  
    HTML; preg_match("/<\?xml[^>]+>(.*)<\/soap:Envelope>/is",$str,$arr);
     echo $arr[0];