㈠ php如何用soap传递xml
请参考:开源中国社区里边的这边文章:
php调用web services两种方法soap and xml-rpc
连接:my.oschina.net/adamboy/blog/29569
㈡ php如何传送xml文件或者数据
使用fopen 或者file_get_contents等进行远程获取。
㈢ php输出xml内容
PHP生成XML的方法很多,这里演示最基本,最简单的字符串构造法。就是使用字符串构造或者拼接成xml数据格式,然后输出或者生成xml文件。
<?php
$data=array(
array(
'title'=>'',
'country'=>'china',
'name'=>'网络',
),
array(
'title'=>'google',
'country'=>'usa',
'name'=>'谷歌',
)
);
//构造xml数据格式
$xml="<?xmlversion="1.0"encoding="utf-8"?> ";
$xml.="<data> ";
foreach($dataas$itm){
//循环构造xml单项
$item="<item> ";
$item.="<title>".$itm['title']."</title> ";
$item.="<country>".$itm['country']."</country> ";
$item.="<name>".$itm['name']."</name> ";
$item.="</item> ";
$xml.=$item;
}
$xml.="</data> ";
//输出xml数据
echo$xml;
?>
生成的数据格式如下:
㈣ php如何调用xml文件
推荐用simpleXML处理xml,举例如下:
$xml=simplexml_load_file('http://www.w3schools.com/xml/plant_catalog.xml');
foreach($xml->PLANTas$plantNode){
echo$plantNode->COMMON,'-',$plantNode->PRICE," ";
}
㈤ php 如何发送xml报文
<?php
if($_SERVER['REQUEST_METHOD']==='POST'){
//接收
$content=file_get_contents('php://input');
$xml=simplexml_load_string($content);
echo"来自XML接收方的响应 ";
print_r(get_object_vars($xml));
exit;
}
//发送行为
$xml=<<<xml
<?xmlversion="1.0"?>
<FOX>
<hello>world</hello>
</FOX>
xml;
$setting=array(
'http'=>array(
'method'=>'POST',
'user_agent'=>'<ClientApplicationName>',
'header'=>"Content-type:application/x-www-form-urlencoded",
'content'=>$xml
)
);
$context=stream_context_create($setting);
$url='http://localhost/'.$_SERVER['REQUEST_URI'];
$response=file_get_contents($url,null,$context);
echo$response;
CURL是可以的,但是参数设置比较麻烦。这种情况有一些现成的类库实现,提供一个简单的示例
㈥ PHp怎么获取网络传过来的xml文件
<?php
$xml_string=file_get_contents("php://input");
$xml_string=trim($xml_string);
$xml_object=simplexml_load_string($xml_string);
$xml_arr=get_object_vars($xml_object);
只要别人访问你这个文件传递xml。你就能获取其中的信息了。
㈦ php如何通过xml传递数据
获取request中body的字符串数据,比如一个数组转成xml后,你用post方式给服务器发送xml的字符串,服务器就用file_get_contents('php://input') 去读取xml格式 然后转成数组即可
㈧ php 从数据库里面读取数据后怎么写成xml传输
用PHP读取数据库中的数据 - >输出XML文档 - >在Flash中加载XML
㈨ php如何post XML到指定服务器
以下是一个编写好的postXML的类:
<?php
classxmlSender{
/**
*构造器
*校验cURL是不是可用
*/
functionxmlSender()
{
if(!extension_loaded('curl')){
trigger_error("",E_USER_ERROR);
}
}
/**
*使用了cURL库发送xml内容
*/
functionsend($str_xml,$str_url,$str_page,$boo_ssl=false)
{
$str_header="POST".$str_page."HTTP/1.0 ";
$str_header.="MIME-Version:1.0 ";
$str_header.="Content-type:application/PTI26 ";
$str_header.="Content-length:".strlen($str_xml)." ";
$str_header.="Content-transfer-encoding:text ";
$str_header.="Request-number:1 ";
$str_header.="Document-type:Response ";
$str_header.="Interface-Version:Site1.0 ";
$str_header.="Connection:close ";
$str_header.=$str_xml;
$res_curl=curl_init();
curl_setopt($res_curl,CURLOPT_URL,$str_url);
curl_setopt($res_curl,CURLOPT_RETURNTRANSFER,1);
curl_setopt($res_curl,CURLOPT_TIMEOUT,30);
curl_setopt($res_curl,CURLOPT_CUSTOMREQUEST,$str_header);
curl_setopt($res_curl,CURLOPT_FOLLOWLOCATION,1);
if($boo_ssl){
curl_setopt($res_curl,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($res_curl,CURLOPT_SSL_VERIFYPEER,false);
}
$str_data=curl_exec($res_curl);
if(curl_errno($res_curl)){
trigger_error(curl_error($res_curl),E_USER_ERROR);
}else{
curl_close($res_curl);
}
return$str_data;
}
}
$str_xml='<xxx>blablabla</xxx><yyy>blebleble</yyy><zzzz>bliblibli</zzz>';
$o=newxmlSender;
print_r($o->send($str_xml,"https://endereco.com.br/","/yyy/x.x.x/",true));
?>
=========================================
这几天我正在研究cURL,这个库正好能够完成你的需要,具体代码的编写需要示例数据与网站才能测试,以下是post的示例:
<?php
$url='http://www.example.com/submit.php';
//Thesubmittedformdata,encodedasquery-string-style
//name-valuepairs
$body='monkey=uncle&rhino=aunt';
$c=curl_init($url);
curl_setopt($c,CURLOPT_POST,true);
curl_setopt($c,CURLOPT_POSTFIELDS,$body);
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
$page=curl_exec($c);
curl_close($c);
?>
㈩ php输出xml文件应该如何写
最简单的办法就是拼凑:
echo '<?xml version="1.0" encoding="utf-8" ?>';
echo '<skplyaer>';
ech ...
echo '</ckplayer'>;