title: LOAD XML LOCAL INFILE with Inconsistent Column Names
body: <p>MySQL has a nice statement: LOAD XML LOCAL INFILE</p>
  
  <p>For example, if you have this table: </p>
  
  <pre><code> CREATE TABLE person (
      person_id INT NOT NULL PRIMARY KEY,
      fname VARCHAR(40) NULL,
      lname VARCHAR(40) NULL
   );
  </code></pre>
  
  <p>and the following XML file called person.xml: </p>
  
  <pre><code>&lt;list&gt;
        &lt;person&gt;
            &lt;person_id&gt;1&lt;/person_id&gt;
            &lt;fname&gt;Mikael&lt;/fname&gt;
            &lt;lname&gt;Ronström&lt;/lname&gt;
        &lt;/person&gt;
        &lt;person&gt;
            &lt;person_id&gt;2&lt;/person_id&gt;
            &lt;fname&gt;Lars&lt;/fname&gt;
            &lt;lname&gt;Thalmann&lt;/lname&gt;
        &lt;/person&gt;
  &lt;/list&gt;
  </code></pre>
  
  <p>You can do this: </p>
  
  <pre><code>LOAD XML LOCAL INFILE 'person.xml'
  INTO TABLE person
  ROWS IDENTIFIED BY '&lt;person&gt;';
  </code></pre>
  
  <p>My question is, what if the column names were different in the XML file than they are in the table? For example: </p>
  
  <pre><code>&lt;list&gt;
        &lt;person&gt;
            &lt;PersonId&gt;1&lt;/PersonId&gt;
            &lt;FirstName&gt;Mikael&lt;/FirstName&gt;
            &lt;LastName&gt;Ronström&lt;/LastName&gt;
        &lt;/person&gt;
        &lt;person&gt;
            &lt;PersonId&gt;2&lt;/PersonId&gt;
            &lt;FirstName&gt;Lars&lt;/FirstName&gt;
            &lt;LastName&gt;Thalmann&lt;/LastName&gt;
        &lt;/person&gt;
  &lt;/list&gt;
  </code></pre>
  
  <p>How can you accomplish the same thing with a MySQL statement without manipulating the XML file? I searched everywhere but couldn't find an answer. </p>