Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are only trying to <strong>read</strong> some data from an XML string, the simplest way would probably be to use <a href="http://fr2.php.net/simplexml" rel="nofollow noreferrer">SimpleXML</a>, and not <a href="http://fr.php.net/dom" rel="nofollow noreferrer">DOM</a> -- DOM is well suited when it comes to writing XML, but for reading, SimpleXML is much easy to work with.</p> <p>For instance, you could use something like this as a starting point : <br>Note I used the <a href="http://fr2.php.net/manual/en/function.simplexml-load-string.php" rel="nofollow noreferrer"><code>simplexml_load_string</code></a> function to load the XML string.</p> <pre><code>$string = &lt;&lt;&lt;STR &lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;payer&gt; &lt;purchase_list&gt; &lt;freeform_purchase&gt; &lt;line_number&gt;1&lt;/line_number&gt; &lt;description&gt;description&lt;/description&gt; &lt;price_including_vat&gt;12&lt;/price_including_vat&gt; &lt;vat_percentage&gt; 15 &lt;/vat_percentage&gt; &lt;quantity&gt;10&lt;/quantity&gt; &lt;/freeform_purchase&gt; &lt;/purchase_list&gt; &lt;payment_urls&gt; &lt;auth_url&gt;authurl&lt;/auth_url&gt; &lt;settle_url&gt;settleurl&lt;/settle_url&gt; &lt;/payment_urls&gt; &lt;/payer&gt; STR; $xml = simplexml_load_string($string); echo intval($xml-&gt;purchase_list-&gt;freeform_purchase-&gt;price_including_vat) . '&lt;br /&gt;'; echo (string)$xml-&gt;payment_urls-&gt;auth_url . '&lt;br /&gt;'; </code></pre> <p>Which would give you the following output :</p> <pre><code>12 authurl </code></pre> <p>Basically, with SimpleXML, the XML tree is available as an object -- the root node of the XML not being present in the tree, as it's the root ; which is why I didn't have to include <code>payer</code> to access the data.</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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