title: Unable to read data into SQL Server 2005 from an XML file
body: <p>I am trying to use the following script to read data from an XML file and insert it into a table called <code>TermsTree</code> on SQL Server 2005. </p>
  
  <pre><code>INSERT INTO TermsTree (TermID,ParentID,Name)
  
  SELECT X.TermsTree.query('TermID').value('.', 'INT'),
         X.TermsTree.query('ParentID').value('.', 'INT'),
         X.TermsTree.query('Name').value('.', 'VARCHAR(2000)')
  FROM (
  
  SELECT CAST(x AS XML)
  FROM OPENROWSET(
      BULK 'C:\Users\MehtabM\Desktop\GetAllTermTree.xml',
      SINGLE_BLOB) AS T(x)
      ) AS T(x)
  CROSS APPLY x.nodes('ArrayOfTerm_Child/Term_Child') AS X(TermsTree);
  </code></pre>
  
  <p>A sample of the XML file is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;ArrayOfTerm_Child xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/"&gt;
      &lt;Term_Child&gt;
          &lt;TermID&gt;2021&lt;/TermID&gt;
          &lt;Name&gt;A. Geographic locations&lt;/Name&gt;
          &lt;ParentID&gt;0&lt;/ParentID&gt;
      &lt;/Term_Child&gt;
      &lt;Term_Child&gt;
          &lt;TermID&gt;3602&lt;/TermID&gt;
          &lt;Name&gt;Oceania&lt;/Name&gt;
          &lt;ParentID&gt;2021&lt;/ParentID&gt;
      &lt;/Term_Child&gt;
      &lt;Term_Child&gt;
          &lt;TermID&gt;3604&lt;/TermID&gt;
          &lt;Name&gt;Australasia&lt;/Name&gt;
          &lt;ParentID&gt;3602&lt;/ParentID&gt;
      &lt;/Term_Child&gt;
      &lt;/Term_Child&gt;
  &lt;/ArrayOfTerm_Child&gt;
  </code></pre>