Note that there are some explanatory texts on larger screens.

plurals
  1. POCatalyst XML datafeed
    primarykey
    data
    text
    <p>I'm trying to output the data from an XML file datafeed, the support documents are pretty poor and I'm having trouble looping through the XML.</p> <pre><code>SimpleXMLElement Object ( [@attributes] =&gt; Array ( [version] =&gt; 6 [type] =&gt; WEB [date] =&gt; 20120220 ) [account] =&gt; SimpleXMLElement Object ( [@attributes] =&gt; Array ( [code] =&gt; XXXX ) [sites] =&gt; SimpleXMLElement Object ( [site] =&gt; SimpleXMLElement Object ( [@attributes] =&gt; Array ( [code] =&gt; XXXX ) [name] =&gt; Name [address1] =&gt; Address 1 [address2] =&gt; town [address3] =&gt; UK [county] =&gt; County [postcode] =&gt; Postcode [phone] =&gt; 0123456789 [fax] =&gt; 0123456789 [vehicles] =&gt; SimpleXMLElement Object ( [vehicle] =&gt; Array ( [0] =&gt; SimpleXMLElement Object ( [@attributes] =&gt; Array ( [code] =&gt; 5956 [new] =&gt; N [engineSize] =&gt; 998 [mileage] =&gt; 8000 [type] =&gt; MC [reg] =&gt; XXX [regDate] =&gt; 20070414 [created] =&gt; 20110928090130 [modified] =&gt; 20110928090130 ) [manufacturer] =&gt; Honda [description] =&gt; CBR 1000 RR-7 [colour] =&gt; Black [body] =&gt; Motorcycle [fuel] =&gt; Petrol [status] =&gt; In Stock ) [1] =&gt; SimpleXMLElement Object ( [@attributes] =&gt; Array ( [code] =&gt; 5958 [new] =&gt; Y [engineSize] =&gt; 125 [type] =&gt; MC [created] =&gt; 20110930090254 [modified] =&gt; 20110930090254 ) [manufacturer] =&gt; Honda [description] =&gt; WW125EX2A [colour] =&gt; BLACK(NHA35) [body] =&gt; SCOOTER [status] =&gt; In Stock [category] =&gt; SCOOTER ) ) ) ) ) ) </code></pre> <p>The data is loaded by:</p> <pre><code>$request = "&lt;"."?xml version='1.0' encoding='iso-8859-1'?"."&gt;". "&lt;download account='XXXX' password='XXXX' version='6' request='EXP' format='XML' dealer='XXXX' vehicles='Y' /&gt;"; $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/xml", "Content-Length: " . strlen($request))); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_URL, 'https://www.catalyst-findit.co.uk/download.php'); $response = curl_exec($ch); $xml = simplexml_load_string($response); print_r($xml); </code></pre> <p>I'm mainly interested in the vehicle data, which I have tried to load by:</p> <pre><code>echo (string) $xml-&gt;vehicles-&gt;vehicle[0]; </code></pre> <p>Although this doesn't seem to work.</p> <p>Be grateful if anybody could offer any advice :)</p> <p>Thanks in advance.</p> <p><strong>Edit</strong> XML file (displaying only two vehicles for easy reading):</p> <pre><code>&lt;?xml version="1.0" encoding="iso-8859-1"?&gt; &lt;findit xmlns="http://www.catalyst-findit.co.uk/download" version="6" type="WEB" date="20120220"&gt; &lt;account code="XXX"&gt; &lt;sites&gt; &lt;site code="BRI"&gt; &lt;name&gt;XXX&lt;/name&gt; &lt;address1&gt;XXX&lt;/address1&gt; &lt;address2&gt;XXX&lt;/address2&gt; &lt;address3&gt;XXX&lt;/address3&gt; &lt;county&gt;XXX&lt;/county&gt; &lt;postcode&gt;XXX&lt;/postcode&gt; &lt;phone&gt;01472 123456&lt;/phone&gt; &lt;fax&gt;01472 123456&lt;/fax&gt; &lt;vehicles&gt; &lt;vehicle code="XXX" new="N" engineSize="998" mileage="8000" type="MC" reg="XXX" regDate="20070414" created="20110928090130" modified="20110928090130"&gt; &lt;manufacturer&gt;Honda&lt;/manufacturer&gt; &lt;description&gt;CBR 1000 RR-7&lt;/description&gt; &lt;colour&gt;Black&lt;/colour&gt; &lt;body&gt;Motorcycle&lt;/body&gt; &lt;fuel&gt;Petrol&lt;/fuel&gt; &lt;status&gt;In Stock&lt;/status&gt; &lt;/vehicle&gt; &lt;vehicle code="XXX" new="Y" engineSize="125" type="MC" created="20110930090254" modified="20110930090254"&gt; &lt;manufacturer&gt;Honda&lt;/manufacturer&gt; &lt;description&gt;XXX&lt;/description&gt; &lt;colour&gt;BLACK(NHA35)&lt;/colour&gt; &lt;body&gt;SCOOTER&lt;/body&gt; &lt;status&gt;In Stock&lt;/status&gt; &lt;category&gt;SCOOTER&lt;/category&gt; &lt;/vehicle&gt; &lt;/vehicles&gt; &lt;/site&gt; &lt;/sites&gt; &lt;/account&gt; &lt;/findit&gt; </code></pre>
    singulars
    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