在PHP中从SOAP响应中提取数据

时间:2017-03-16 14:59:21

标签: php xml xslt soap xml-parsing

我有来自OSvC的XML响应,我想处理它以提取sfdc_record_id并打印其值 a0t4C000000I8YPQA0
如何在PHP中打印该数据?

<pre>
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
        <env:Header/>
        <env:Body>
            <rnm_v1_3:process xmlns:rnb_v1_3="urn:base.ws.rightnow.com/v1_3" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:rnf_v1_3="urn:faults.ws.rightnow.com/v1_3" xmlns:nstrgmpr="http://xmlns.oracle.com/cloud/adapter/rightnow/GetServiceRequest_REQUEST/types" xmlns:rnn_v1_3="urn:nullfields.ws.rightnow.com/v1_3" xmlns:rno_v1_3="urn:objects.ws.rightnow.com/v1_3" xmlns:plnk="http://schemas.xmlsoap.org/ws/2003/05/partner-link/" xmlns:rnw_v1_3="urn:wsdl.ws.rightnow.com/v1_3" xmlns:nstrgdfl="http://xmlns.oracle.com/ics/tracking/ics_tracking_context.xsd" xmlns:rna_v1_3="urn:metadata.ws.rightnow.com/v1_3" xmlns:rnm_v1_3="urn:messages.ws.rightnow.com/v1_3" xmlns:ns1="http://xmlns.oracle.com/cloud/adapter/rightnow/GetServiceRequest_REQUEST" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:rng_v1_3="urn:generic.ws.rightnow.com/v1_3" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
                <rnm_v1_3:RNObjects xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="rno_v1_3:Incident">
                    <rnb_v1_3:ID id="376"/>
                    <rno_v1_3:Asset>
                        <rnb_v1_3:Name>true</rnb_v1_3:Name>
                    </rno_v1_3:Asset>
                    <rno_v1_3:AssignedTo>
                        <rno_v1_3:Account>
                            <rnb_v1_3:Name/>
                        </rno_v1_3:Account>
                    </rno_v1_3:AssignedTo>
                    <rno_v1_3:Banner>
                        <rno_v1_3:Text>false</rno_v1_3:Text>
                    </rno_v1_3:Banner>
                    <rno_v1_3:IncidentCustomFields>
                        <rno_v1_3:sfdc_record_id>a0t4C000000I8YPQA0</rno_v1_3:sfdc_record_id>
                    </rno_v1_3:IncidentCustomFields>
                    <rno_v1_3:PrimaryContact>
                        <rno_v1_3:Contact>
                            <rnb_v1_3:ID id=""/>
                        </rno_v1_3:Contact>
                    </rno_v1_3:PrimaryContact>
                </rnm_v1_3:RNObjects>
            </rnm_v1_3:process>
        </env:Body>
    </env:Envelope>
</pre>

1 个答案:

答案 0 :(得分:1)

希望这对你有用:

PHP Code demo