Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't read XML with simplexml_load_file PHP
    primarykey
    data
    text
    <p>So i am trying to parse data from an XML url and insert it into a table using php, which can be seen <a href="http://json.zandparts.com/api/category/GetCategories/44/EUR/ET10B/E%20Series/AC%20Adapter/Asus/null" rel="nofollow">here</a>, (please keep in mind there are more products than displayed on this page, i am not trying to get it for just this Product,the code below shows how i am parsing all products) but i keep getting the following errors:</p> <hr> <p><strong>[EDITED]</strong></p> <pre><code>class DataGrabber { //The URL where data will be extracted from, which is an XML file protected $URL = "http://json.zandparts.com/api/category/GetCategories/44/EUR/"; public function call_api($data) { if(count($data) == 0) return array(); $jsondata = array(); foreach($data as $entry){ $url = $this-&gt;URL . $entry['model'] . "/" . urlencode($entry['family']) . "/" . urlencode($entry['cat']) . "/" . $entry['man'] . "/null"; $json = file_get_contents($url); $data = json_decode($json, true); if(!empty($data['Products'])){ foreach ($data['Products'] as $id =&gt; $product) { $jsonentry = array( 'productnumber' =&gt; $id, 'partnumber' =&gt; $product['strPartNumber'], 'description' =&gt; $product['strDescription'], 'manu' =&gt; $product['Brand'] ); $jsondata[] = $jsonentry; } } } return $jsondata; } </code></pre> <p>}</p> <hr> <p><strong>[NEW ERRORS]</strong></p> <p>So i have fixed the error:</p> <pre><code>PHP Warning: file_get_contents(http://json.zandparts.com/api/category/GetCategories/44/EUR/ET10B/E Series/AC Adapter/Asus/null): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/svn/dev.comp/Asus.php on line 82 </code></pre> <p>by using <code>urlencode</code> as shown in my code above</p> <p>This warning below isnt finding the values for the url:</p> <pre><code>PHP Warning: file_get_contents(http://json.zandparts.com/api/category/GetCategories/44/EUR///04G265003580/Asus/null): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found </code></pre> <p>as you can see after, <code>44/EUR</code> there are three forward slashes with no data?? How would i resolve this??</p>
    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