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

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

      <tfoot id='harwk'></tfoot>

          <bdo id='harwk'></bdo><ul id='harwk'></ul>

        simplexml_load_string() 不会读取带有“soap:"的so

        时间:2023-05-22
        <tfoot id='NMxrs'></tfoot>

            <tbody id='NMxrs'></tbody>
            <bdo id='NMxrs'></bdo><ul id='NMxrs'></ul>

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

                <legend id='NMxrs'><style id='NMxrs'><dir id='NMxrs'><q id='NMxrs'></q></dir></style></legend>
                  本文介绍了simplexml_load_string() 不会读取带有“soap:"的soap响应;在标签中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我知道这可能是一个新手问题,但请逗我笑.当读取标签中带有soap:"的 xml 字符串时,simplexml_load_string() 不会读取到 xml.

                  I know this may be a newbie question, but please humor me. When reading an xml string with "soap:" in the tags, simplexml_load_string() will not read in the xml.

                  给定这个脚本:

                  #!/usr/bin/php
                  <?php
                  
                  $s='
                      <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
                          <soap:Header>
                          <context xmlns="urn:zimbra"/>
                          </soap:Header>
                          <soap:Body>
                              <AuthResponse xmlns="urn:zimbraAdmin">
                                  <authToken>somevalue</authToken>
                                  <lifetime>123124123</lifetime>
                                  <a n="zimbraIsDomainAdminAccount">false</a>
                              </AuthResponse>
                          </soap:Body>
                      </soap:Envelope>';
                  
                  
                  print_r(simplexml_load_string($s));
                  echo "
                  
                  ";
                  print_r(simplexml_load_string(str_ireplace("soap:", "", $s)));
                  ?>
                  

                  我得到这个输出:

                  jesse@jesse-debian:~/code/zmsoap$ ./xmltest.php 
                  SimpleXMLElement Object
                  (
                  )
                  
                  SimpleXMLElement Object
                  (
                      [Header] => SimpleXMLElement Object
                          (
                              [context] => SimpleXMLElement Object
                                  (
                                  )
                  
                          )
                  
                      [Body] => SimpleXMLElement Object
                          (
                              [AuthResponse] => SimpleXMLElement Object
                                  (
                                      [authToken] => somevalue
                                      [lifetime] => 123124123
                                      [a] => false
                                  )
                  
                          )
                  
                  )
                  jesse@jesse-debian:~/code/zmsoap$
                  

                  我只是很好奇为什么会发生这种情况,以及是否有比进行字符串替换更合适的方法来解决该问题.

                  I'm just curious why this is happening, and if there is a more proper way to remedy the problem as opposed to doing a string replace.

                  推荐答案

                  带有冒号 in 的标记名称表示该标记位于非默认命名空间中.SimpleXML 一次只查看一个命名空间,因此您需要使用 ->children() 方法.

                  A tag name with a colon in indicates the tag is in a non-default namespace. SimpleXML only looks at one namespace at a time, so you need to specifically select the namespace using the ->children() method.

                  在这种情况下 $xml->children('http://www.w3.org/2003/05/soap-envelope')->Body$xml->children('soap', true)->Body 应该都可以.

                  In this case $xml->children('http://www.w3.org/2003/05/soap-envelope')->Body or $xml->children('soap', true)->Body should both work.

                  出于这个和其他原因,不建议使用 print_r 来调试 SimpleXML 对象.试试这个专用功能.

                  For this and other reasons, it's not advisable to use print_r to debug SimpleXML objects. Try this dedicated function instead.

                  这篇关于simplexml_load_string() 不会读取带有“soap:"的soap响应;在标签中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在php中读取soap响应xml 下一篇:使用 PHP 进行 SOAP 身份验证

                  相关文章

                  最新文章

                1. <small id='Qq77d'></small><noframes id='Qq77d'>

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

                    <tfoot id='Qq77d'></tfoot>