title: Import XML with attributes into mysql
body: <p>I have a large (~30Mb) XML file like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes" ?&gt;
  &lt;LIC Version="2.0" Title="Products"&gt;
      &lt;Item&gt;
          &lt;Field Name="Filename"&gt;/root/_DOWNLOAD/Bird.txt&lt;/Field&gt;
          &lt;Field Name="Read_By"&gt;Lisa Hannigan&lt;/Field&gt;
          &lt;Field Name="Posit"&gt;Passenger&lt;/Field&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;Field Name="Filename"&gt;D:\03\Strypers.pdf&lt;/Field&gt;
          &lt;Field Name="Read_By"&gt;Stryper&lt;/Field&gt;
          &lt;Field Name="Intensity"&gt;2&lt;/Field&gt;
          &lt;Field Name="IMG"&gt;78&lt;/Field&gt;
          &lt;Field Name="Rotate"&gt;0&lt;/Field&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;Field Name="Filename"&gt;D:\Afriu.txt&lt;/Field&gt;
          &lt;Field Name="Read_By"&gt;Africano&lt;/Field&gt;
          &lt;Field Name="Posit"&gt;Canto Africano vol.1&lt;/Field&gt;
          &lt;Field Name="File_Resource"&gt;mp3&lt;/Field&gt;
      &lt;/Item&gt;
      &lt;Item&gt;
          &lt;Field Name="Filename"&gt;D:\_VARIOUS\Knots.pdf&lt;/Field&gt;
          &lt;Field Name="Date"&gt;40624&lt;/Field&gt;
      &lt;/Item&gt;
      ...
  &lt;/LIC&gt;
  </code></pre>
  
  <p>I want to import this xml into mysql database, with a php script. I've used SIMPLEXML and xpath:</p>
  
  <pre><code>    $url = 'FILE.xml';
      $xml = simplexml_load_file($url);
      $result = $xml-&gt;xpath("//Field[@Name]");
  foreach { ... }
  </code></pre>
  
  <p>What do i need? What is the correct "foreach" to create an array to use for mysql sql?
  Notes that every row (identify by "Item") is not same (not have the same "Field Name").
  Is it correct to use simplexml for larger file?
  Thank you for help!</p>
  
  <p><em>update</em></p>
  
  <p>This is an example to use "foreach", i tried:</p>
  
  <pre><code>$result = $xml-&gt;xpath("//Field[@Name]");    
  foreach($result as $key =&gt; $value)  {
      echo $value['Name']."=".$value.",";
   }
  </code></pre>
  
  <p>Now I want to find out how to create the string to insert in mysql  </p>