Note that there are some explanatory texts on larger screens.

plurals
  1. POGet content from XML PHP5
    primarykey
    data
    text
    <p>I´m working on a paymentsolution and need some help with the PHP. I´m doing a HTTPRequest and in response I will get some XML. The XML Could look like this: </p> <pre><code>&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; </code></pre> <p>Basically what I want to do is to get the content from the tags and save them in strings.</p> <p>I tried this: </p> <pre><code>$order = '&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;'; $orderXML = new DOMDocument(); $orderXML-&gt;load($order); $payerXML = $orderXML-&gt;getElementsByTagName( 'payer' ); $purchase_listXML = $orderXML-&gt;getElementsByTagName( 'purchase_list' ); $freeform_purchaseXML = $orderXML-&gt;getElementsByTagName( 'freeform_purchase' ); $linenumberXML = $orderXML-&gt;getElementsByTagName( 'line_number' ); $descriptionXML = $orderXML-&gt;getElementsByTagName( 'description' ); $price_inc_vatXML = $orderXML-&gt;getElementsByTagName( 'price_including_vat' ); $vat_percentageXML = $orderXML-&gt;getElementsByTagName( 'vat_percentage' ); $quantityXML = $orderXML-&gt;getElementsByTagName( 'quantity' ); $settle_urlXML = $orderXML-&gt;getElementsByTagName( 'settle_url' ); $auth_urlXML = $orderXML-&gt;getElementsByTagName( 'auth_url' ); $theLineNumber = $linenumberXML-&gt;item(0)-&gt;nodeValue; $theValue = $descriptionXML-&gt;item(0)-&gt;nodeValue; $freeform_price = $price_inc_vatXML-&gt;item(0)-&gt;nodeValue; $freeform_vat = $vat_percentageXML-&gt;item(0)-&gt;nodeValue; $freeform_quantity = $quantityXML-&gt;item(0)-&gt;nodeValue; $Settle_url = $settle_urlXML-&gt;item(0)-&gt;nodeValue; $Auth_url = $auth_urlXML-&gt;item(0)-&gt;nodeValue; echo 'thLineNumber - ' . $theLineNumber; echo $theValue; echo $freeform_price; echo $freeform_vat; echo $freeform_quantity; echo $Settle_url; echo $Auth_url; </code></pre> <p>But obviously there is something wrong since it won´t echo anything.. Suggestions?</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.
 

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