Note that there are some explanatory texts on larger screens.

plurals
  1. POXML parsing fails with simplexml_load_string()
    primarykey
    data
    text
    <p>This is my XML response I am getting from on of the API I am using </p> <pre><code>resParam&lt;?xml version="1.0"?&gt; &lt;response&gt; &lt;status&gt;OK&lt;/status&gt; &lt;order&gt; &lt;id&gt;137656566936059014&lt;/id&gt; &lt;order_date&gt;2013-08-15 12:21:09&lt;/order_date&gt; &lt;price&gt;50.00&lt;/price&gt; &lt;payment&gt;UNPAID&lt;/payment&gt; &lt;payment_type&gt;0&lt;/payment_type&gt; &lt;order_type&gt;delivery&lt;/order_type&gt; &lt;status&gt;2&lt;/status&gt; &lt;details&gt;sample&lt;/details&gt; &lt;user&gt; &lt;name&gt;-&lt;/name&gt; &lt;telephone&gt;&lt;/telephone&gt; &lt;address_line_1&gt;*ND*SC&lt;/address_line_1&gt; &lt;address_line_2&gt;-&lt;/address_line_2&gt; &lt;postcode&gt;*ND*FODSC&lt;/postcode&gt; &lt;town&gt;&lt;/town&gt; &lt;distance&gt;*ND*POINTS&lt;/distance&gt; &lt;/user&gt; &lt;/order&gt; &lt;/response&gt; </code></pre> <p>There is <code>resParam</code> at the starting of the response. I tried without that string by storing into a variable like this</p> <pre><code>$string = '&lt;?xml version="1.0"?&gt; [ response xml content from API ] '; $xml = simplexml_load_string($string ); //returns correct empty object print_r( $xml ); </code></pre> <p>It is returning result but not the first method with the string <code>resParam</code> infront of it .I tried <code>str_replace</code> then it is returning this</p> <pre><code>&lt; xsi:type="xsd:string"&gt;&lt;?xml version="1.0"?&gt; &lt;response&gt; &lt;status&gt;OK&lt;/status&gt; &lt;order&gt; &lt;id&gt;137656566936059014&lt;/id&gt; &lt;order_date&gt;2013-08-15 12:21:09&lt;/order_date&gt; &lt;price&gt;50.00&lt;/price&gt; &lt;payment&gt;UNPAID&lt;/payment&gt; &lt;payment_type&gt;0&lt;/payment_type&gt; &lt;order_type&gt;delivery&lt;/order_type&gt; &lt;status&gt;2&lt;/status&gt; &lt;details&gt;sample&lt;/details&gt; &lt;user&gt; &lt;name&gt;-&lt;/name&gt; &lt;telephone&gt;&lt;/telephone&gt; &lt;address_line_1&gt;*ND*SC&lt;/address_line_1&gt; &lt;address_line_2&gt;-&lt;/address_line_2&gt; &lt;postcode&gt;*ND*FODSC&lt;/postcode&gt; &lt;town&gt;&lt;/town&gt; &lt;distance&gt;*ND*POINTS&lt;/distance&gt; &lt;/user&gt; &lt;/order&gt; &lt;/response&gt; </code></pre> <p>What is this extra <code>&lt; xsi:type="xsd:string"&gt;</code> in this result?</p> <p>Can anyone help me in this? Or what am i doing wrong? How can i parse this</p> <p><strong>Edit:</strong></p> <p>When i inspected the result with firebug it is this what i get</p> <pre><code>&lt;env:envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="urn:myOutputNamespace" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:enc="http://www.w3.org/2003/05/soap-encoding"&gt;&lt;env:body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc"&gt;&lt;ns1:getorderresponse env:encodingstyle="http://www.w3.org/2003/05/soap-encoding"&gt;&lt;rpc:result&gt;&lt;/rpc:result&gt;&lt;!--?xml version="1.0"?--&gt; &lt;response&gt; &lt;status&gt;OK&lt;/status&gt; &lt;order&gt; &lt;id&gt;137656566936059014&lt;/id&gt; &lt;order_date&gt;2013-08-15 12:21:09&lt;/order_date&gt; &lt;price&gt;50.00&lt;/price&gt; &lt;payment&gt;UNPAID&lt;/payment&gt; &lt;payment_type&gt;0&lt;/payment_type&gt; &lt;order_type&gt;delivery&lt;/order_type&gt; &lt;status&gt;2&lt;/status&gt; &lt;details&gt;sample&lt;/details&gt; &lt;user&gt; &lt;name&gt;-&lt;/name&gt; &lt;telephone&gt;&lt;/telephone&gt; &lt;address_line_1&gt;*ND*SC&lt;/address_line_1&gt; &lt;address_line_2&gt;-&lt;/address_line_2&gt; &lt;postcode&gt;*ND*FODSC&lt;/postcode&gt; &lt;town&gt;&lt;/town&gt; &lt;distance&gt;*ND*POINTS&lt;/distance&gt; &lt;/user&gt; &lt;/order&gt; &lt;/response&gt;&lt;/ns1:getorderresponse&gt;&lt;/env:body&gt;&lt;/env:envelope&gt; </code></pre> <p>I need data inside response tag only. How can i do that? I think this attempt will solve the problem.</p>
    singulars
    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.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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