Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing xpath on a PHP SimpleXML object, SOAP + namespaces (not working..)
    primarykey
    data
    text
    <p>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)</p> <p>First this is the XML:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; &lt;soap:Header xmlns="http://webservices.site.com/definitions"&gt; &lt;SessionId&gt;0119A|1&lt;/SessionId&gt; &lt;/soap:Header&gt; &lt;soap:Body&gt; &lt;Security_AuthenticateReply xmlns="http://xml.site.com/QQ"&gt; &lt;processStatus&gt; &lt;statusCode&gt;P&lt;/statusCode&gt; &lt;/processStatus&gt; &lt;/Security_AuthenticateReply&gt; &lt;/soap:Body&gt; &lt;/soap:Envelope&gt; </code></pre> <p>Now this is what my code in PHP looks like:</p> <pre><code>$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-&gt;registerXPathNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"); $_res = $response-&gt;xpath('//soap:Header'); print_r($_res); /*** result: simple query for the root "soap" namespace, this looks good! (so far..) Array ( [0] =&gt; SimpleXMLElement Object ( [SessionId] =&gt; 0119A|1 ) ) ***/ // now we query for the "SessionId" element in the XML $_res = $response-&gt;xpath('//soap:Header/SessionId'); print_r($_res); /*** result: this does not return anything! Array ( ) ***/ // another approach $_res = $response-&gt;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-&gt;xpath('//soap:Header'); $_res = (string)$_res[0]-&gt;SessionId; echo $_res; /*** result: this worked 0119A|1 ***/ </code></pre> <p>How can I get the SOAP message working with XPATH???</p> <p>Thanks, Roman</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload