XML解析失败?解决办法
程序员文章站
2022-06-14 08:32:57
...
XML解析失败?
XMLDATA:
address="net.tcp://192.168.1.61:9003/class/"
binding="netTcpBinding"
contract="CiWong.Relation.WCFContract.IClassRelationManager"
bindingConfiguration="NetTcpBinding_IClassRelationManager" />
address="net.tcp://192.168.1.61:9005/eshop/"
binding="netTcpBinding"
contract="CiWong.EShop.WCFService.Contract.IEShopContract"
bindingConfiguration="NetTcpBinding_IEShopContract"/>
解析代码:
$list=$doc->getElementsByTagName('system.serviceModel');
$list=$list->item(0);
$clients=$list->getElementsByTagName('client');
$clients=$clients->item(0);
foreach ($clients->attributes as $endpoints) {
$endattname=$endpoints->nodeName;
$endattval=$endpoints->nodeValue;
echo "$endattname=$endattval"."
";
}
?>
echo出来没有任何内容。
请问怎么才能正常把endpoint里面的属性解析出来?
------解决方案--------------------
XMLDATA:
binding="netTcpBinding"
contract="CiWong.Relation.WCFContract.IClassRelationManager"
bindingConfiguration="NetTcpBinding_IClassRelationManager" />
binding="netTcpBinding"
contract="CiWong.EShop.WCFService.Contract.IEShopContract"
bindingConfiguration="NetTcpBinding_IEShopContract"/>
解析代码:
$list=$doc->getElementsByTagName('system.serviceModel');
$list=$list->item(0);
$clients=$list->getElementsByTagName('client');
$clients=$clients->item(0);
foreach ($clients->attributes as $endpoints) {
$endattname=$endpoints->nodeName;
$endattval=$endpoints->nodeValue;
echo "$endattname=$endattval"."
";
}
?>
echo出来没有任何内容。
请问怎么才能正常把endpoint里面的属性解析出来?
------解决方案--------------------
- PHP code
$xml = simplexml_load_file("bb.xml"); $result = $xml->xpath('/configuration/system.serviceModel/client/endpoint');foreach($result as $r){ foreach($r->attributes() as $k=>$v) echo "$k=>$v
";}相关文章
相关视频
上一篇: 解决Tk的窗口左上角位置设定不正确问题
下一篇: 问个菜鸟的关于数组的有关问题
推荐阅读