欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP 以POST方式提交XML、獲取XML,解析XML詳解及實例

 更新時間:2016年10月26日 15:34:01   投稿:lqh  
這篇文章主要介紹了PHP 以POST方式提交XML、獲取XML,解析XML詳解及實例的相關(guān)資料,需要的朋友可以參考下

PHP 以POST方式提交XML、獲取XML,最后解析XML

以POST方式提交XML

// Do a POST
$data="<?xml version='1.0' encoding='UTF-8'?>
<TypeRsp>
<CONNECT_ID>1</CONNECT_ID>
<MO_MESSAGE_ID>2</MO_MESSAGE_ID>
</TypeRsp>";

//$data = array('name' => 'Dennis', 'surname' => 'Pallett');

// create a new curl resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL,"http://localhost/handle_form.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
// grab URL, and print
curl_exec($ch);

獲取POST來到XML,并解析

handle_form.php


$file_in = file_get_contents("php://input"); //接收post數(shù)據(jù)

$xml = simplexml_load_string($file_in);//轉(zhuǎn)換post數(shù)據(jù)為simplexml對象

foreach($xml->children() as $child)  //遍歷所有節(jié)點數(shù)據(jù)
{

echo $child->getName() . ": " . $child . "<br />"; //打印節(jié)點名稱和節(jié)點值

//if($child->getName()=="from")  //撿取要操作的節(jié)點
//{
//echo "i say ". ": get you!" . "<br />"; //操作節(jié)點數(shù)據(jù)
//}
}

exit;

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論