ผมต้องส่งค่า request ไปที่ host ที่หนึ่งโดยทาง host เค้าให้คู่มือมาว่าจะตอบกลับ (response ) เป็น
format xml ซึ่งผมก็ได้ทำการจำลองการส่งดู localhost โดยได้รับค่า response กลับมาเป็น 200
แต่เป็น response ธรรมดา และติดค่า xml มาด้วย
โดยโค้ดหน้าส่งเป็นอย่างนี้ครับ
โค้ด: เลือกทั้งหมด
<?
$fp = fsockopen("$host", 80, $errno, $errstr, 30);
if (!$fp)
{
echo "$errstr ($errno)\n";
}
else
{
fwrite($fp,"POST /test.php HTTP/1.0\r\nHost: localhost\r\n\r\n$data");
$x="";
while (!feof($fp)) {
$x=$x.fgets($fp, 128);
}
fclose($fp);
?>
HTTP/1.1 200 OK Date: Thu, 17 Jul 2008 03:29:59 GMT Server: Apache/2.2.3 (Win32) PHP/5.1.6 X-Powered-By: PHP/5.1.6 Content-Length: 82 Connection: close Content-Type: text/xml; charset=UTF-8 200
ซึ่งถ้ากดดู view source จะเห็นดังนี้ครับ
HTTP/1.1 200 OK
Date: Thu, 17 Jul 2008 03:29:59 GMT
Server: Apache/2.2.3 (Win32) PHP/5.1.6
X-Powered-By: PHP/5.1.6
Content-Length: 82
Connection: close
Content-Type: text/xml; charset=UTF-8
<cpa-wap>
<cpa-response>
<status>200</status>
</cpa-response>
</cpa-wap>
ซึ่งผมเห็นว่ามีค่า tag xml ติดมาแต่ปัญหาคือผมจะแยกเอาค่านั้นอย่างไรครับ
ซึ่งผมได้ทำการลองใช้ DOMDocument ดูก็ไม่ได้ครับ