title: Import XML into MySQL database
body: <p>I'm new to coding, trying to create a database from an XML file which is a list of industries, company names and symbols. I've seen a few examples of a PHP code that imports the data into MySQL which looked something like:</p>
  
  <pre><code>&lt;?php
  
  $url ="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.industry%20where%20id%20in%20(select%20industry.id%20from%20yahoo.finance.sectors)&amp;env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_URL, $url); //getting url contents
  
  $data = curl_exec ($ch); //execule curl request
  curl_close($ch);
  
  $xml = simplexml_load_string($data);
  
  $con=mysql_connect("localhost", "root", ""); //connect to server
  mysql_select_db("symbol_list", $con) or die(mysql_error()); //select database
  
  foreach ($xml -&gt; item as $row) {
      $industry = $row -&gt; industry;
      $company = $row -&gt; name;
      $symbol = $row -&gt; symbol;
  
  // perform sql query
  
  
  $sql = "INSERT INTO 'symbols_xml' ('industry', 'company', 'symbol')"
      . "VALUES ('$industry', '$company', '$symbol')";
  
  $result = mysql_query($sql);
  if (!$result) {
      echo 'MySQL ERROR';
  } else {
  
      echo 'SUCCESS';
  }
  
  
                              }
  
  ?&gt;
  </code></pre>
  
  <p>However, because the XML is formatted like this:</p>
  
  <pre><code>&lt;query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="215" yahoo:created="2015-03-02T20:58:57Z" yahoo:lang="en-US"&gt;
  &lt;results&gt;
  &lt;industry id="112" name="Agricultural Chemicals"&gt;
      &lt;company name="Adarsh Plant Protect Ltd" symbol="ADARSHPL.BO"/&gt;
      &lt;company name="African Potash Ltd" symbol="AFPO.L"/&gt;
      ......
  &lt;/industry&gt;
  &lt;industry id="132" name="Aluminum"&gt;
      &lt;company name="AEI Corp Ltd" symbol="A18.SI"/&gt;
      &lt;company name="Alcoa Inc" symbol="AA.BA"/&gt;
      &lt;company name="Alcoa Inc" symbol="AA.MX"/&gt;
      ......
  </code></pre>
  
  <p>My PHP code above is unable to recognise the values...
  Is there any way to import the attributes (industry name, company name and symbol) so that it looks something like:</p>
  
  <pre><code>    #| Industry  | Company    | Symbol
      -|----------- ------------ -------
      1| Aluminium | Alcoa Inc. | AA.BA
  </code></pre>
  
  <p>and so on..</p>
  
  <p>I just recently started learning PHP and databases so please forgive me if this is a noobish question that wasted your time. xD</p>
  
  <p>Thanks.</p>