SimpleXML 不显示值
SimpleXML doesn't show the value
我想知道为什么下面的代码没有显示 processResponse 标签的值,而它显示了整个 XML 和 Body 标签。
这是我正在处理的XML
$xml = '<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:df1231asfer5e4564affds</wsa:MessageID>
<wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo>
</env:Header>
<env:Body>
<processResponse xmlns="http://xmlns.oracle.com/EligibilityProcess/EligibilityProcess/EligibilityBPEL">
<generatedMessageRefNo>451</generatedMessageRefNo>
<providerRefNo>41</providerRefNo>
<tpaRequestId>4184612387</tpaRequestId>
<contractHolder>Rami Zbeeb</contractHolder>
<contractNo>81456954</contractNo>
<guarantorName>ANC</guarantorName>
<eligibilityStatus>Success</eligibilityStatus>
<eligibilityReason xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<messageOrNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<patientShare></patientShare>
<consentForm></consentForm>
<webServTechStatus>Success</webServTechStatus>
<replyCode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<replyDescription xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</processResponse></env:Body></env:Envelope>';
我正在使用简单XML class:
$res = new SimpleXMLElement($xml);
当我展示正文时 XML 它起作用了:
$str = $res->children('env',true)->Body->asXML();
echo "<pre>",htmlentities($str),"</pre>";
然而,当显示 processResponse XML 或字符串时,它不起作用:
$str = $res->children('env',true)->Body->processResponse->asXML();
echo "<pre>",htmlentities($str),"</pre>";
多多指教。
你可以得到Body
的children得到processResponse
:
$str = $res->children('env',true)->Body->children()->processResponse->asXML();
echo "<pre>",htmlentities($str),"</pre>";
我想知道为什么下面的代码没有显示 processResponse 标签的值,而它显示了整个 XML 和 Body 标签。
这是我正在处理的XML
$xml = '<?xml version="1.0"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<env:Header>
<wsa:MessageID>urn:df1231asfer5e4564affds</wsa:MessageID>
<wsa:ReplyTo><wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address></wsa:ReplyTo>
</env:Header>
<env:Body>
<processResponse xmlns="http://xmlns.oracle.com/EligibilityProcess/EligibilityProcess/EligibilityBPEL">
<generatedMessageRefNo>451</generatedMessageRefNo>
<providerRefNo>41</providerRefNo>
<tpaRequestId>4184612387</tpaRequestId>
<contractHolder>Rami Zbeeb</contractHolder>
<contractNo>81456954</contractNo>
<guarantorName>ANC</guarantorName>
<eligibilityStatus>Success</eligibilityStatus>
<eligibilityReason xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<messageOrNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<patientShare></patientShare>
<consentForm></consentForm>
<webServTechStatus>Success</webServTechStatus>
<replyCode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<replyDescription xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
</processResponse></env:Body></env:Envelope>';
我正在使用简单XML class:
$res = new SimpleXMLElement($xml);
当我展示正文时 XML 它起作用了:
$str = $res->children('env',true)->Body->asXML();
echo "<pre>",htmlentities($str),"</pre>";
然而,当显示 processResponse XML 或字符串时,它不起作用:
$str = $res->children('env',true)->Body->processResponse->asXML();
echo "<pre>",htmlentities($str),"</pre>";
多多指教。
你可以得到Body
的children得到processResponse
:
$str = $res->children('env',true)->Body->children()->processResponse->asXML();
echo "<pre>",htmlentities($str),"</pre>";