<legend id='ZVUf7'><style id='ZVUf7'><dir id='ZVUf7'><q id='ZVUf7'></q></dir></style></legend>
  • <small id='ZVUf7'></small><noframes id='ZVUf7'>

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

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

      1. SimpleXML SOAP 响应命名空间问题

        SimpleXML SOAP response Namespace issues(SimpleXML SOAP 响应命名空间问题)
          <legend id='pMv6F'><style id='pMv6F'><dir id='pMv6F'><q id='pMv6F'></q></dir></style></legend>
        1. <i id='pMv6F'><tr id='pMv6F'><dt id='pMv6F'><q id='pMv6F'><span id='pMv6F'><b id='pMv6F'><form id='pMv6F'><ins id='pMv6F'></ins><ul id='pMv6F'></ul><sub id='pMv6F'></sub></form><legend id='pMv6F'></legend><bdo id='pMv6F'><pre id='pMv6F'><center id='pMv6F'></center></pre></bdo></b><th id='pMv6F'></th></span></q></dt></tr></i><div id='pMv6F'><tfoot id='pMv6F'></tfoot><dl id='pMv6F'><fieldset id='pMv6F'></fieldset></dl></div>

              • <bdo id='pMv6F'></bdo><ul id='pMv6F'></ul>
                  <tbody id='pMv6F'></tbody>

                <tfoot id='pMv6F'></tfoot>

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

                  本文介绍了SimpleXML SOAP 响应命名空间问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在为此花费了几个令人沮丧的小时后,我正在寻求您的帮助.

                  我正在尝试从 SOAP 响应中获取特定节点的内容.

                  回应是

                  <?xml version="1.0" encoding="UTF-8"?><env:信封 xmlns:env="<a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/肥皂信封</a>"<xmlns:ns1="<a href="http://soap.xxxxxx.co.uk/">http://soap.xxxxxx.co.uk/</a>"><env:身体><ns1:PlaceOrderResponse><xxxxxOrderNumber></xxxxxOrderNumber><错误数组><错误><错误代码>24</错误代码><ErrorText>+client+order+number+3002254+is+already+in+use</ErrorText></错误><错误><错误代码>1</错误代码><ErrorText>正在中止</ErrorText></错误></错误数组></ns1:PlaceOrderResponse></env:正文></env:信封>

                  我正在尝试获取 <ErrorArray> 的节点和子节点.由于 XML 包含命名空间

                  $XmlArray = new SimpleXMLElement($XmlStr);foreach ($XmlArray->env:Envelope->env:Body->ns1:PlaceOrderResponse->ErrorArray->Error as $Error){echo $Error->ErrorCode."<br/>";}

                  不起作用.我已经阅读了许多文章,例如

                  • http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/
                  • http://blog.stuartherbert.com/php/2007/01/07/using-simplexml-to-parse-rss-feeds/

                  还有关于这个网站的大约 20 个问题,很遗憾没有帮助.

                  即使写作,

                  $XmlArray = new SimpleXMLElement($XmlStr);echo "<br/><br/><pre>
                  ";print_r($XmlArray);echo "<pre><br/><br/>
                  ";

                  给予

                  SimpleXMLElement 对象()

                  这让我想知道肥皂响应 ($XmlStr) 是否实际上是 SimpleXMLElement 的有效输入.

                  好像是行

                  $XmlArray = new SimpleXMLElement($XmlStr);

                  没有按照我的预期去做.

                  非常欢迎任何有关如何从上述 XML 中获取节点的帮助.

                  显然,让它发挥作用(有一个有效的例子)是我在短期内需要的,但如果有人能帮助我理解我做错了什么,从长远来看会更好.

                  干杯.斯图

                  解决方案

                  你必须使用 SimpleXMLElement::children(),尽管此时使用 XPath 可能会更容易.

                  children("env", true)->Body->children("ns1", true)->PlaceOrderResponse->children()->ErrorArray->Error;foreach ($t as $error) {echo $error->ErrorCode, " " , $error->ErrorText, "<br/>";}

                  给予:

                  <上一页>24 The+client+order+number+3002254+is+already+in+use1 中止

                  After spending SEVERAL frustrated hours on this I am asking for your help.

                  I am trying to get the content of particular nodes from a SOAP response.

                  The response is

                  <?xml version="1.0" encoding="UTF-8"?>
                  <env:Envelope xmlns:env="<a href="http://www.w3.org/2003/05/soap-envelope">http://www.w3.org/2003/05/soap-envelope</a>"<xmlns:ns1="<a href="http://soap.xxxxxx.co.uk/">http://soap.xxxxxx.co.uk/</a>">
                      <env:Body>
                          <ns1:PlaceOrderResponse>
                              <xxxxxOrderNumber></xxxxxOrderNumber>
                              <ErrorArray>
                                  <Error>
                                      <ErrorCode>24</ErrorCode>
                                      <ErrorText>The+client+order+number+3002254+is+already+in+use</ErrorText>
                                  </Error>
                                  <Error>
                                      <ErrorCode>1</ErrorCode>
                                      <ErrorText>Aborting</ErrorText>
                                  </Error>
                              </ErrorArray>
                          </ns1:PlaceOrderResponse>
                      </env:Body>
                  </env:Envelope>
                  

                  I am trying to get at the nodes and children of <ErrorArray>. Because of the XML containing namespaces

                  $XmlArray   = new SimpleXMLElement($XmlStr);
                  
                  foreach ($XmlArray->env:Envelope->env:Body->ns1:PlaceOrderResponse->ErrorArray->Error as $Error)
                  {
                      echo $Error->ErrorCode."<br />";
                  }
                  

                  doesn't work. I have read a number of articles such as

                  • http://www.sitepoint.com/blogs/2005/10/20/simplexml-and-namespaces/
                  • http://blog.stuartherbert.com/php/2007/01/07/using-simplexml-to-parse-rss-feeds/

                  and about 20 questions on this site, which unfortunately are not helping.

                  Even writing,

                  $XmlArray   = new SimpleXMLElement($XmlStr);
                  
                  echo "<br /><br /><pre>
                  ";
                  print_r($XmlArray);
                  echo "<pre><br /><br />
                  ";
                  

                  gives

                  SimpleXMLElement Object
                  (
                  )
                  

                  which makes me wonder if the soap response ($XmlStr) is actually a valid input for SimpleXMLElement.

                  It seems that the line

                  $XmlArray   = new SimpleXMLElement($XmlStr);
                  

                  is not doing what I expect it to.

                  Any help on how to get the nodes from the XML above would be very welcome.

                  Obviously getting it to work (having a working example) is what I need in the short term, but if someone could help me understand what I am doing wrong would be better in the long term.

                  Cheers. Stu

                  解决方案

                  You have to use SimpleXMLElement::children(), though at this point it would probably be easier to use XPath.

                  <?php
                      $XmlStr = <<<XML
                  <?xml version="1.0" encoding="UTF-8"?>
                  <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"  xmlns:ns1="http://soap.xxxxxx.co.uk/" >
                      <env:Body>
                          <ns1:PlaceOrderResponse>
                              <xxxxxOrderNumber></xxxxxOrderNumber>
                              <ErrorArray>
                                  <Error>
                                      <ErrorCode>24</ErrorCode>
                                      <ErrorText>The+client+order+number+3002254+is+already+in+use</ErrorText>
                                  </Error>
                                  <Error>
                                      <ErrorCode>1</ErrorCode>
                                      <ErrorText>Aborting</ErrorText>
                                  </Error>
                              </ErrorArray>
                          </ns1:PlaceOrderResponse>
                      </env:Body>
                  </env:Envelope>
                  XML;
                  
                      $XmlArray   = new SimpleXMLElement($XmlStr);
                  
                      $t = $XmlArray->children("env", true)->Body->
                          children("ns1", true)->PlaceOrderResponse->
                          children()->ErrorArray->Error;
                      foreach ($t as $error) {
                          echo $error->ErrorCode, " " , $error->ErrorText, "<br />";
                      } 
                  

                  gives:

                  24 The+client+order+number+3002254+is+already+in+use
                  1 Aborting
                  

                  这篇关于SimpleXML SOAP 响应命名空间问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <i id='MGOOj'><tr id='MGOOj'><dt id='MGOOj'><q id='MGOOj'><span id='MGOOj'><b id='MGOOj'><form id='MGOOj'><ins id='MGOOj'></ins><ul id='MGOOj'></ul><sub id='MGOOj'></sub></form><legend id='MGOOj'></legend><bdo id='MGOOj'><pre id='MGOOj'><center id='MGOOj'></center></pre></bdo></b><th id='MGOOj'></th></span></q></dt></tr></i><div id='MGOOj'><tfoot id='MGOOj'></tfoot><dl id='MGOOj'><fieldset id='MGOOj'></fieldset></dl></div>
                  • <tfoot id='MGOOj'></tfoot>

                      <tbody id='MGOOj'></tbody>

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

                      • <bdo id='MGOOj'></bdo><ul id='MGOOj'></ul>
                        • <legend id='MGOOj'><style id='MGOOj'><dir id='MGOOj'><q id='MGOOj'></q></dir></style></legend>