一、接收xml数据, 使用php://input,代码如下:
<?php
$xmldata=file_get_contents("php://input");
$data=simplexml_load_string($xmldata);
print_r($data);
?>
二、使用CURL发送xml数据,代码如下:
<?php
$xml = file_get_contents('1.xml');
$url = "http://test.xxx.com/xxx.php";
$header[]="Content-type: text/xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_HTTPHEADER,$header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);
?>
?>