您的位置:首页 > 编程语言 > PHP开发

php获取通过http协议post提交过来xml数据及解析xml

2012-12-16 00:00 1096 查看
php 如何获取请求的xml数据,对方通过http协议post提交过来xml数据,php如何获取到这些数据呢?
<?php 
$xml_data ='<AATAvailReq1>'. 
'<Agency>'. 
'<Iata>1234567890</Iata>'. 
'<Agent>lgsoftwares</Agent>'. 
'<Password>mypassword</Password>'. 
'<Brand>phpmind.com</Brand>'. 
'</Agency>'. 
'<Passengers>'. 
'<Adult AGE="" ID="1"></Adult>'. 
'<Adult AGE="" ID="2"></Adult>'. 
'</Passengers>'. 
'<HotelAvailReq1>'. 
'<DestCode>JHM</DestCode>'. 
'<HotelCode>OGGSHE</HotelCode>'. 
'<CheckInDate>101009</CheckInDate>'. 
'<CheckOutDate>101509</CheckOutDate>'. 
'<UseField>1</UseField>'. 
'</HotelAvailReq1>'. 
'</AATAvailReq1>'; 
$URL = "https://www.yourwebserver.com/path/"; 
$ch = curl_init($URL); 
curl_setopt($ch, CURLOPT_MUTE, 1); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); 
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data"); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$output = curl_exec($ch); 
curl_close($ch); 
?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐