XML parsing failed? XMLDATA: & lt; configuration & gt; & lt; system. serviceModel & gt; & nbsp; & lt; client & gt; & nbsp; & lt; endpointname = & quot; ClassRelationServic XML parsing failed?
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. ies?contract"
BindingConfiguration = "nettcpbinding_ies?contract"/>
Parsing code:
$ 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 "."
";
}
?>
There is no content from the echo.
How can I parse the endpoint attributes normally?
------ Solution --------------------
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
";}