<?xml version="1.0" encoding="GB2312" ?>
- <rt_parse ret_value="1">
<pnr>VPR2Z</pnr>
- <passengers count="1">
- <passenger>
<Name>王文东</Name>
<NI />
</passenger>
</passengers>
- <lines count="1">
- <Line>
<AirLine>MU5116</AirLine>
<Cabin>H</Cabin>
<Discount>80</Discount>
<DepartureCity>PEK</DepartureCity>
<DestinationCity>SHA</DestinationCity>
<DepartureAirPort>北京首都机场</DepartureAirPort>
<DestinationAirPort>上海虹桥机场</DestinationAirPort>
<Date>12NOV</Date>
<State>RR</State>
<StartTime>15:00</StartTime>
<ArriveTime>17:05</ArriveTime>
</Line>
</lines>
- <tickets count="1">
<ticket>7812569854520</ticket>
</tickets>
</rt_parse>我要求用php把里面的参数值给取出来,请高手提供代码参考……
- <rt_parse ret_value="1">
<pnr>VPR2Z</pnr>
- <passengers count="1">
- <passenger>
<Name>王文东</Name>
<NI />
</passenger>
</passengers>
- <lines count="1">
- <Line>
<AirLine>MU5116</AirLine>
<Cabin>H</Cabin>
<Discount>80</Discount>
<DepartureCity>PEK</DepartureCity>
<DestinationCity>SHA</DestinationCity>
<DepartureAirPort>北京首都机场</DepartureAirPort>
<DestinationAirPort>上海虹桥机场</DestinationAirPort>
<Date>12NOV</Date>
<State>RR</State>
<StartTime>15:00</StartTime>
<ArriveTime>17:05</ArriveTime>
</Line>
</lines>
- <tickets count="1">
<ticket>7812569854520</ticket>
</tickets>
</rt_parse>我要求用php把里面的参数值给取出来,请高手提供代码参考……
解决方案 »
- php 报错。。。。
- 弱类型好吗?好在哪,我不知道
- 代码意思不太明白
- 上来散分咯
- php实现按条件确定按钮状态
- linux下,无法调用mssql请教
- 用PHP在xampp+Dreamweaver+PHP_Maile环境下r实现发送邮件功能
- zend studio 运行php脚本出现no test was executed 和 error launch "new configuration"
- linux apache 服务器 中问的文件名下载 404 但是在ie中可以
- THINKPHP网站登录页在本地测试可以正常登录,在服务器却跳转到一个不存在的文件。
- PHP循环添加记录到MYSQL数据库的问题!请看例子…………在线等候,急…………
- 我看到一些PHP代码使用memcache的时候用MD5以后的SQL语句作为Key来查询,为何?为什么不直接用SQL语句作为Key呢?
$xml = simplexml_load_string($string);
print_r($xml);需使用php5
function show(){
var xmlDoc=xmlHttp.responseXML;
var yan=xmlDoc.getElementsByTagName("content");
var ta = "<table border=1 cellspacing=0 width=80% align=\"center\" id=ta><tr><td align=\"center\" width=\"100\" background=\"./images/Data_Bg.gif\">任务</td><td align=\"center\" width=\"100\" background=\"./images/Data_Bg.gif\">执行人名称</td><td align=\"center\" background=\"./images/Data_Bg.gif\">任务名称</td><td align=\"center\" background=\"./images/Data_Bg.gif\">开始时间</td><td align=\"center\" background=\"./images/Data_Bg.gif\">完成时间</td><td align=\"center\" background=\"./images/Data_Bg.gif\">开始任务</td><td align=\"center\" background=\"./images/Data_Bg.gif\">暂停任务</td><td align=\"center\" background=\"./images/Data_Bg.gif\">结束任务</td></tr>";
for(var i=0;i<yan.length;i++){
var y=yan[i];
var taskid=y.childNodes[0].firstChild.data;
var taskname=y.childNodes[1].firstChild.data;
var executename=y.childNodes[2].firstChild.data;
var begintime=y.childNodes[3].firstChild.data;
var endtime=y.childNodes[4].firstChild.data;
var start=y.childNodes[5].firstChild.data;
var finish=y.childNodes[6].firstChild.data;
var ifpause=y.childNodes[7].firstChild.data;
if(ifpause==null){
ifpause="0";
}
ta+="<tr id=\"aa\"><td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+(i+1)+"</td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+executename+"</td>";
ta+="<td width=\"400\" align=\"center\" background=\"./images/Data_Bg.gif\">"+taskname+"</td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+begintime+"</td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+endtime+"</td>";
if(start=="xxx"){
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"开始任务\" onclick=\"starttask('"+taskid+"')\"/></td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"开始暂停\" onclick=\"window.alert('任务没开始,你不能暂停任务!')\"/></td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"结束任务\" onclick=\"window.alert('任务没开始,你不能结束任务!')\"/></td></tr>";
}else{
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+start+"</td>";
if(finish=="xxx"){
if(ifpause=="1"){
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"结束暂停\" onclick=\"endpause('"+taskid+"')\"/></td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"结束任务\" onclick=\"window.alert('暂停没结束,你不能结束任务!')\"/></td></tr>";
}else if(ifpause=="0"){
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"开始暂停\" onclick=\"window.location.href('javascript:open("+taskid+")')\"/></td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\"><input type=\"button\" value=\"结束任务\" onclick=\"endtask('"+taskid+"')\"/></td></tr>";
}
}else{
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">任务已结束</td>";
ta+="<td width=\"100\" align=\"center\" background=\"./images/Data_Bg.gif\">"+finish+"</td></tr>";
}
}
}
ta+="</table>";
alert("您好,你今天有"+yan.length+"个任务需要执行!加油!");
document.getElementById("res").innerHTML=ta;
setTimeout("newvalidate()",1000);
}</script>这是我们做绩效的一个用ajax解析xml的一个函数 你自己琢磨下吧
$doc->load('test1.xml');
$root = $doc->documentElement;
$pnr = $root->getElementsByTagName('pnr');
echo $pnr->item(0)->nodeValue; // <pnr>VPR2Z</pnr>
echo '<br/>';$passengers = $root->getElementsByTagName('passengers');
echo $passengers->item(0)->getAttribute('count'); // <passengers count="1">
echo '<br/>';$passenger = $root->getElementsByTagName('passenger');
echo iconv("UTF-8","GB2312",$passenger->item(0)->nodeValue); //<name>王文东</name>
echo '<br/>';$passengers = $root->getElementsByTagName('lines');
echo $passengers->item(0)->getAttribute('count'); // <lines count="1">
echo '<br/>';
其它的类似方法
直接用$root->getElementsByTagName('xxxx');来取。
给你一个地址 你去看一下 应该就明白了~ 选择一种适合自己的
http://www.ibm.com/developerworks/cn/opensource/os-xmldomphp/