Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I process an XML file with php?
    primarykey
    data
    text
    <p>My gateway sends(posts) my server an xml datafeed when a purchase is made. The XML looks something like this:</p> <pre><code> &lt;?xml version='1.0' standalone='yes'?&gt; &lt;foxydata&gt; &lt;datafeed_version&gt;XML FoxyCart Version 0.6&lt;/datafeed_version&gt; &lt;transactions&gt; &lt;transaction&gt; &lt;id&gt;616&lt;/id&gt; &lt;transaction_date&gt;2007-05-04 20:53:57&lt;/transaction_date&gt; &lt;customer_id&gt;122&lt;/customer_id&gt; &lt;customer_first_name&gt;Dirk&lt;/customer_first_name&gt; &lt;customer_last_name&gt;Gently&lt;/customer_last_name&gt; &lt;shipping_total&gt;4.38&lt;/shipping_total&gt; &lt;order_total&gt;24.38&lt;/order_total&gt; &lt;order_total&gt;24.38&lt;/order_total&gt; &lt;customer_password&gt;1aab23051b24582c5dc8e23fc595d505&lt;/customer_password&gt; &lt;custom_fields&gt; &lt;custom_field&gt; &lt;custom_field_name&gt;My_Cool_Text&lt;/custom_field_name&gt; &lt;custom_field_value&gt;Value123&lt;/custom_field_value&gt; &lt;/custom_field&gt; &lt;/custom_fields&gt; &lt;transaction_details&gt; &lt;transaction_detail&gt; &lt;product_name&gt;foo&lt;/product_name&gt; &lt;product_price&gt;20.00&lt;/product_price&gt; &lt;product_quantity&gt;1&lt;/product_quantity&gt; &lt;product_weight&gt;0.10&lt;/product_weight&gt; &lt;product_code&gt;&lt;/product_code&gt; &lt;subscription_frequency&gt;1m&lt;/subscription_frequency&gt; &lt;subscription_startdate&gt;2007-07-07&lt;/subscription_startdate&gt; &lt;next_transaction_date&gt;2007-08-07&lt;/next_transaction_date&gt; &lt;shipto&gt;John Doe&lt;/shipto&gt; &lt;category_description&gt;Default for all products&lt;/category_description&gt; &lt;category_code&gt;DEFAULT&lt;/category_code&gt; &lt;product_delivery_type&gt;shipped&lt;/product_delivery_type&gt; &lt;transaction_detail_options&gt; &lt;transaction_detail_option&gt; &lt;product_option_name&gt;color&lt;/product_option_name&gt; &lt;product_option_value&gt;blue&lt;/product_option_value&gt; &lt;price_mod&gt;&lt;/price_mod&gt; &lt;weight_mod&gt;&lt;/weight_mod&gt; &lt;/transaction_detail_option&gt; &lt;/transaction_detail_options&gt; &lt;/transaction_detail&gt; &lt;/transaction_details&gt; &lt;shipto_addresses&gt; &lt;shipto_address&gt; &lt;address_name&gt;John Doe&lt;/address_name&gt; &lt;shipto_first_name&gt;John&lt;/shipto_first_name&gt; &lt;shipto_last_name&gt;Doe&lt;/shipto_last_name&gt; &lt;shipto_address1&gt;2345 Some Address&lt;/shipto_address1&gt; &lt;shipto_address2&gt;&lt;/shipto_address2&gt; &lt;shipto_city&gt;Some City&lt;/shipto_city&gt; &lt;shipto_state&gt;TN&lt;/shipto_state&gt; &lt;shipto_postal_code&gt;37013&lt;/shipto_postal_code&gt; &lt;shipto_country&gt;US&lt;/shipto_country&gt; &lt;shipto_shipping_service_description&gt;DHL: Next Afternoon&lt;/shipto_shipping_service_description&gt; &lt;shipto_subtotal&gt;52.15&lt;/shipto_subtotal&gt; &lt;shipto_tax_total&gt;6.31&lt;/shipto_tax_total&gt; &lt;shipto_shipping_total&gt;15.76&lt;/shipto_shipping_total&gt; &lt;shipto_total&gt;74.22&lt;/shipto_total&gt; &lt;shipto_custom_fields&gt; &lt;shipto_custom_field&gt; &lt;shipto_custom_field_name&gt;My_Custom_Info&lt;/shipto_custom_field_name&gt; &lt;shipto_custom_field_value&gt;john's stuff&lt;/shipto_custom_field_value&gt; &lt;/shipto_custom_field&gt; &lt;shipto_custom_field&gt; &lt;shipto_custom_field_name&gt;More_Custom_Info&lt;/shipto_custom_field_name&gt; &lt;shipto_custom_field_value&gt;more of john's stuff&lt;/shipto_custom_field_value&gt; &lt;/shipto_custom_field&gt; &lt;/shipto_custom_fields&gt; &lt;/shipto_address&gt; &lt;/shipto_addresses&gt; &lt;/transaction&gt; &lt;/transactions&gt; &lt;/foxydata&gt; XML; </code></pre> <p>As a first time XML parsing experiencing, I was hoping somebody could show me how I would go about going through and turning this into a php array or something like that so I can then insert the data I want into a mysql table.</p> <p>Whats the easiest way to go about doing this?</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