我已经尝试过并且无法提出解决方案。 我的问题是: 我有一个SOAP信封响应,如下所示...... p>
< soapenv:envelope xmlns:soapenv =“http://schemas.xmlsoap .org / soap / envelope /“>
< soapenv:header>
< soapenv:body>
< mcu:prescreenusereligibilityresponse xmlns:mcu =”http://www.ups.com/XMLSchema/ XOLTWS / MCUserEligibility / v1.0“>
< common:response xmlns:common =”http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0“>
< common: responsestatus>
< common:code> 1< / common:code>
< common:description> Success< / common:description>
< / common:responsestatus>
< / common:response>
< mcu:eligibilitystatuscode> 3< / mcu:eligibilitystatuscode>
< / mcu:prescreenusereligibilityresponse>
< / soapenv:body>
< / soapenv:header>
< / soapenv:envelope>
< / code> pre>
然后我在我的mac上访问这样的元素: p>
$ ns = array();
$ xml = new SimpleXMLElement($ string);
foreach($ xml-&gt; getNamespaces(true)as $ key =&gt; $ url){
$ xml-&gt; registerXPathNamespace($ key,$ url);
$ ns [] = strval($网址);
}
print_r(strval($ XML-&GT;儿童($ NS [0]) - &GT;报头 - &GT;身体 - &GT;儿童($ NS [1] ) - &gt; prescreenusereligibilityresponse-&gt; eligibilitystatuscode));
code> pre>
在单独的Linux实例上使用相同的方法我在 print_r上出错了 code> line,表示最后一个子节点不能为null。 我已经确认这些值是正确的。 我也尝试使用 $ xml-&gt; xpath('// mcu:eligibilitystatuscode') code>但没有成功。 p>
我真的卡住了-_- p>
div>