<bdo id='9MFGp'></bdo><ul id='9MFGp'></ul>

    <i id='9MFGp'><tr id='9MFGp'><dt id='9MFGp'><q id='9MFGp'><span id='9MFGp'><b id='9MFGp'><form id='9MFGp'><ins id='9MFGp'></ins><ul id='9MFGp'></ul><sub id='9MFGp'></sub></form><legend id='9MFGp'></legend><bdo id='9MFGp'><pre id='9MFGp'><center id='9MFGp'></center></pre></bdo></b><th id='9MFGp'></th></span></q></dt></tr></i><div id='9MFGp'><tfoot id='9MFGp'></tfoot><dl id='9MFGp'><fieldset id='9MFGp'></fieldset></dl></div>
    <legend id='9MFGp'><style id='9MFGp'><dir id='9MFGp'><q id='9MFGp'></q></dir></style></legend>

    <small id='9MFGp'></small><noframes id='9MFGp'>

  1. <tfoot id='9MFGp'></tfoot>
    1. 在 PHP SimpleXML 对象上使用 xpath,SOAP + 命名空间

      时间:2023-05-22
        <tbody id='clDin'></tbody>

          <small id='clDin'></small><noframes id='clDin'>

            <legend id='clDin'><style id='clDin'><dir id='clDin'><q id='clDin'></q></dir></style></legend>
            1. <tfoot id='clDin'></tfoot>
              <i id='clDin'><tr id='clDin'><dt id='clDin'><q id='clDin'><span id='clDin'><b id='clDin'><form id='clDin'><ins id='clDin'></ins><ul id='clDin'></ul><sub id='clDin'></sub></form><legend id='clDin'></legend><bdo id='clDin'><pre id='clDin'><center id='clDin'></center></pre></bdo></b><th id='clDin'></th></span></q></dt></tr></i><div id='clDin'><tfoot id='clDin'></tfoot><dl id='clDin'><fieldset id='clDin'></fieldset></dl></div>
                <bdo id='clDin'></bdo><ul id='clDin'></ul>
                本文介绍了在 PHP SimpleXML 对象上使用 xpath,SOAP + 命名空间(不工作..)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                在 SO 和 google 上研究了几个小时之后......我希望在这里得到一些帮助:(我离运行正则表达式以完全删除命名空间仅一步之遥)

                After researching this on SO and google for hours now... I hope to get some help here: (I am just one step away from running a regex to remove the namespaces completely)

                首先这是 XML:

                <?xml version="1.0" encoding="utf-16"?>
                <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                  <soap:Header xmlns="http://webservices.site.com/definitions">
                    <SessionId>0119A|1</SessionId>
                  </soap:Header>
                  <soap:Body>
                    <Security_AuthenticateReply xmlns="http://xml.site.com/QQ">
                      <processStatus>
                        <statusCode>P</statusCode>
                      </processStatus>
                    </Security_AuthenticateReply>
                  </soap:Body>
                </soap:Envelope>
                

                现在这是我在 PHP 中的代码的样子:

                Now this is what my code in PHP looks like:

                $response = simplexml_load_string( $str ,NULL, 
                false, "http://schemas.xmlsoap.org/soap/envelope/" );
                // just making sure the name space is "registered"
                // but I tested all examples also with this removed
                $response->registerXPathNamespace("soap",
                    "http://schemas.xmlsoap.org/soap/envelope/");
                $_res = $response->xpath('//soap:Header');
                print_r($_res);
                /*** result: simple query for the root "soap" namespace, this looks good! (so far..)
                Array
                (
                    [0] => SimpleXMLElement Object
                        (
                            [SessionId] => 0119A|1
                        )
                
                )
                ***/
                
                // now we query for the "SessionId" element in the XML
                $_res = $response->xpath('//soap:Header/SessionId');
                print_r($_res);
                /*** result: this does not return anything!
                Array
                (
                )
                ***/
                
                // another approach
                $_res = $response->xpath('//soap:Header/SessionId/text()');
                print_r($_res);
                /*** result: this does not return anything at all!
                ***/
                
                // Finally, without using XPath this does work
                $_res = $response->xpath('//soap:Header');
                $_res = (string)$_res[0]->SessionId;
                echo $_res;
                /*** result: this worked
                0119A|1
                ***/
                

                如何使用 XPATH 获取 SOAP 消息???

                How can I get the SOAP message working with XPATH???

                谢谢,罗马

                推荐答案

                多个命名空间都搞砸了,给我添加以下作品

                The multiple namespaces are messing with it, adding the following works for me

                $response->registerXPathNamespace("site", "http://webservices.site.com/definitions");
                $_res = $response->xpath('//site:SessionId');
                

                另请参阅此之前的堆栈溢出问题

                also, see this previous stack overflow question

                这篇关于在 PHP SimpleXML 对象上使用 xpath,SOAP + 命名空间(不工作..)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:SoapClient:如何传递多个同名元素? 下一篇:PHP 致命错误:“消息中指定的 SOAP 操作''与

                相关文章

                最新文章

                <small id='pf3T8'></small><noframes id='pf3T8'>

                1. <legend id='pf3T8'><style id='pf3T8'><dir id='pf3T8'><q id='pf3T8'></q></dir></style></legend>
                2. <tfoot id='pf3T8'></tfoot>
                  • <bdo id='pf3T8'></bdo><ul id='pf3T8'></ul>

                  <i id='pf3T8'><tr id='pf3T8'><dt id='pf3T8'><q id='pf3T8'><span id='pf3T8'><b id='pf3T8'><form id='pf3T8'><ins id='pf3T8'></ins><ul id='pf3T8'></ul><sub id='pf3T8'></sub></form><legend id='pf3T8'></legend><bdo id='pf3T8'><pre id='pf3T8'><center id='pf3T8'></center></pre></bdo></b><th id='pf3T8'></th></span></q></dt></tr></i><div id='pf3T8'><tfoot id='pf3T8'></tfoot><dl id='pf3T8'><fieldset id='pf3T8'></fieldset></dl></div>