下面是请求后返回的数据
如何获取其中的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>
如何获取其中的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>
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>
$flg=0;$str_xml="";
while ($line = fgets($fp)) { if (ereg("^\<\?xml",$line)) {
$flg=1;
}
if($flg){
$str_xml.=$line;
}
}
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];