从XML Object获取值?

时间:2015-12-21 12:40:12

标签: php xml xpath xml-namespaces xpath-2.0

我需要从xml中获取“joinmeetingurl”元素的值。我尝试了以下方式。但它什么也没有回报。请帮我拿取价值。

<?php 

$xml = '<serv:message xmlns:serv="http://www.webex.com/schemas/2002/06/service"
        xmlns:com="http://www.webex.com/schemas/2002/06/common"
        xmlns:meet="http://www.webex.com/schemas/2002/06/service/meeting"
        xmlns:att="http://www.webex.com/schemas/2002/06/service/attendee">
          <serv:header>
            <serv:response>
              <serv:result>SUCCESS</serv:result>
                <serv:gsbstatus>PRIMARY</serv:gsbstatus>
            </serv:response>
          </serv:header>
          <serv:body>
            <serv:bodycontent xsi:type="meet:getjoinurlMeetingResponse"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
              <meet:joinmeetingurl>meetingURL</meet:joinmeetingurl>
           </serv:bodycontent>
        </serv:body>
       </serv:message>';

  $xml = simplexml_load_string($xml);
  $items = $xml->registerXPathNamespace('meet','http://www.webex.com/schemas/2002/06/service/meeting');

  $resp = $xml->xpath('//meet:joinmeetingurl');

?>

我总是为$ resp获取空值。

0 个答案:

没有答案