dongwen4630 2013-11-07 09:20
浏览 122
已采纳

php SimpleXMLElement让孩子们拥有另一个xml命名空间

I have a soap request and I need to parse it and get the Uri from posted XML file

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <q1:login xmlns:q1="THE NAMESPACE I NEED">
            <user xsi:type="xsd:string">user</user>
            <password xsi:type="xsd:string">pass</password>
        </q1:login>
    </soap:Body>
</soap:Envelope>

I load the xml with SimpleXMLElement, I get the <soap:Body element (in $body_node) BUT I can't get it's children (to get it's namespace).

the $body_node->asXML(); returns:

<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <q1:login xmlns:q1="THE NAMESPACE I NEED">
        <user xsi:type="xsd:string">user</user>
        <password xsi:type="xsd:string">pass</password>
    </q1:login>
</soap:Body>

the $body_node->count() return 0; and $body_node->children()->asXML() returns false.

How can I get the login element and it's namespace?

  • 写回答

1条回答 默认 最新

  • douzai6337 2013-11-07 10:22
    关注

    This question is reported as abug in php 5.3. Please check here https://bugs.php.net/bug.php?id=66044

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制