php-reading xml子节点值

时间:2013-05-16 20:58:07

标签: php xml xml-parsing simplexml xml-namespaces

尝试在PHP中获取ds:X509Certificate的节点值。我能够导航到IDPSSODescriptor标签,任何关于如何访问子节点值的指针。

<EntityDescriptor>
      <IDPSSODescriptor>
        <ds:Signature >
             <ds:SignedInfo>..</ds:SignedInfo>
             <ds:SignatureValue>..</ds:SignatureValue>
              <ds:KeyInfo>
                 <ds:X509Data>
                   <ds:X509Certificate/>
                 </ds:X509Data>
               </ds:KeyInfo>
         <test>
         <test2>
      </IDPSSODescriptor>
</EntityDescriptor>

php代码到目前为止工作,

$data = $idp_xml->IDPSSODescriptor->attributes()->ID; 

我试过了,

$xml = new SimpleXMLElement($idp_xml->IDPSSODescriptor);
$data = (string) $xml->ds:Signature[0]->ds:KeyInfo->ds:X509Data->ds:X509Certificate.

1 个答案:

答案 0 :(得分:-1)

http://www.php.net/manual/en/simplexmlelement.children.php

$childNode = $idp_xml->IDPSSODescriptor->children();