在php中获取xml子节点数据

时间:2016-05-25 06:28:28

标签: php xml

知道如何在php中获取此节点<ns2:profileMatchDetailScore>的数据 我试过这段代码

$xml_document = simplexml_load_xml($xml_document);

$ foo_ns_bar = $ xml_document-&gt;儿童(&#39; http://example.com&#39;); echo $ foo_ns_bar-&gt; bar [0]; //打印&#39; baz&#39;

但那不适合我。

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
    <ns2:matchResponse xmlns:ns2="http://xmp.actonomy.com">
        <return>
            <matchCount>1</matchCount>
            <fromHits>0</fromHits>
            <maxHits>10</maxHits>
            <matches>
                <detailScore>
                    <score>0.41281393</score>
                    <contributedScore>0.41281393</contributedScore>
                    <maxContributedScore>1.0</maxContributedScore>
                    <weight>1.0</weight>
                    <occur>MUST</occur>
                    <ns2:profileMatchDetailScore>
                        <score>0.41281393</score>
                        <contributedScore>0.41281393</contributedScore>
                        <maxContributedScore>1.0</maxContributedScore>
                        <weight>1.0</weight>
                        <occur>SHOULD</occur>
                        <ns2:termGroupDetailScore>
                            <score>0.94805205</score><contributedScore>0.2528139</contributedScore>                                <maxContributedScore>0.2666667</maxContributedScore>
                           <weight>1.0</weight>
                            <occur>MUST</occur>
                            <name>JOB_TITLE</name>
                            <ns2:termDetailScore>
                                <score>0.909091</score><contributedScore>0.13852817</contributedScore>                                    <maxContributedScore>0.15238099</maxContributedScore>
                            </ns2:termDetailScore>
                        </ns2:termGroupDetailScore>
                    </ns2:profileMatchDetailScore>
                </detailScore>
            </matches>
        </return>
    </ns2:matchResponse>
</soap:Body>

0 个答案:

没有答案