这篇文章主要介绍了php 以post方式提交xml、获取xml,解析xml详解及实例的相关资料,需要的朋友可以参考下
PHP 以POST方式提交XML、获取XML,最后解析XML
以POST方式提交XML
// Do a POST $data=""; //$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); 1 2
获取POST来到XML,并解析
立即学习“PHP免费学习笔记(深入)”;
handle_form.php
$file_in = file_get_contents("php://input"); //接收post数据
$xml = simplexml_load_string($file_in);//转换post数据为simplexml对象
foreach($xml->children() as $child) //遍历所有节点数据
{
echo $child->getName() . ": " . $child . "
"; //打印节点名称和节点值
//if($child->getName()=="from") //捡取要操作的节点
//{
//echo "i say ". ": get you!" . "
"; //操作节点数据
//}
}
exit;
以上就是本文的全部内容,希望对大家的学习有所帮助。
相关推荐:
PHP+JavaScript实现Cookie的读写、交互操作方法详解










