title: Table formatting for xml returned via CURL from API
body: <p>I am using another company's API to retrieve information from their database, it is being returned to me in XML format. I'm trying to accomplish two things - but am having a couple issues.</p>
  
  <p><strong>1st</strong> I would like to format the raw XML data into a table format, that will be easier to view via browser.</p>
  
  <p><strong>2nd</strong> The data I am receiving is IDs/usernames/passwords/emails. I would like to be able to import that data into my DB so that each userID is a row inserted into the DB (I can do the DB work, I just can't figure out how to process each user individually )</p>
  
  <p>The API formatting is like this <code>&lt;API&gt; &lt;message&gt; &lt;user&gt; &lt;id&gt; &lt;/id&gt; &lt;login&gt; &lt;/login&gt; &lt;password&gt; &lt;/password&gt; &lt;message&gt; &lt;/message&gt; &lt;/API&gt;</code> only there will be hundreds of user's instead of just one. </p>
  
  <p>Whenever I just do a print of $array, I get the data as a big blob as intended. However, when I use the updated code, (below) I receive an error that user is not a valid index. I also receive what looks to be the start of my table, without any data in it (only borders).</p>
  
  <p>If anyone could help me figure out why the table is not receiving data (or give me advice on a better way to do it) I would greatly appreciate it. </p>
  
  <p>Extra points for anyone who can help me figure out number two. </p>
  
  <p>Error is <code>Notice: Undefined index: user in /home/public_html/new/test.php on line 36</code> <strong>line 36 is commented in the code</strong> </p>
  
  <p>Here is the bottom part of my code: </p>
  
  <pre><code>curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  // Method execution
  $result = curl_exec($ch);
  // Close CURL session
  
  $array = json_decode(json_encode((array)simplexml_load_string($result)),1);
  
  $array_user=$array['user']; //line 36
  
  $tab='&lt;table border="1" width="400"&gt;';
  for ($j=1; $j&lt; count($array_user) ; $j++) {
  
    $tab.='&lt;tr&gt;';
    $tab.='&lt;td&gt;'.$array_user[$j]['id'].'&lt;/td&gt;';
    $tab.='&lt;td&gt;'.$array_user[$j]['login'].'&lt;/td&gt;';
    $tab.='&lt;td&gt;'.$array_user[$j]['mail'].'&lt;/td&gt;';
   $tab.='&lt;td&gt;'.$array_user[$j]['date'].'&lt;/td&gt;';
   $tab.='&lt;/tr&gt;';
  }
  
  $tab.='&lt;/table&gt;';
  
  echo $tab;
  
  
  ?&gt;
  </code></pre>