title: Import data into SQLite from XML
body: <p>I am trying to import data stored in a XML file into my SQLite database. The insert query looks something like the following:</p>
  
  <pre><code>INSERT INTO table1 VALUES (rank, name)
  SELECT X.record.query('rank').value('.', 'INT'),
         X.record.query('name').value('.', 'VARCHAR(30)')
  FROM (
    SELECT CAST(x AS XML)
    FROM OPENROWSET(BULK 'data.xml', SINGLE_BLOB) AS T(x)
       ) AS T(x)
  CROSS APPLY x.nodes('data/record') AS X(record);
  </code></pre>
  
  <p>The XML data looks like this:</p>
  
  <pre><code>&lt;data&gt;
      &lt;record&gt;
          &lt;rank&gt;1&lt;/rank&gt;
          &lt;name&gt;One&lt;/name&gt;
      &lt;/record&gt;
      &lt;record&gt;
          &lt;rank&gt;2&lt;/rank&gt;
          &lt;name&gt;Two&lt;/name&gt;
      &lt;/record&gt;
      ...
  &lt;/data&gt;
  </code></pre>
  
  <p>However, I am getting "SQL command not properly ended at the outer SELECT statement, and I can't figure out why. Any ideas?</p>