title: How can I deal with NULL values in data table turning into missing XML elements when inserting in SQL Server?
body: <p>I want to insert data using XML in SQL Server 2005. So I got one datatable from the BackEnd and I passed the DataTable as follows;</p>
  
  <pre><code>     DataSet dsItem = new DataSet();
       DTItem.TableName = "ItemDetails";  //DTItem is the DataTable I got from the BackEnd
       dsItem.Tables.Add(DTItem);
  </code></pre>
  
  <p>My problem is, If any column contains null value then the XML not taking that null column. For ex: Consider this is my DataTable</p>
  
  <pre><code>     JobOrderID             CustomerID
      ------------           ------------
         4        
  </code></pre>
  
  <p>Here CustomerID is null. When I fix the Trace and View, the DataTable which shows empty instead of null.
  So. When I pass the DataTable, the XML does not consider the Null column. It takes as follows</p>
  
  <pre><code> &lt;NewDataSet&gt;
     &lt;ItemDetails&gt;
        &lt;JobOrderID&gt;4&lt;/JobOrderID&gt;
     &lt;/ItemDetails&gt;
   &lt;/NewDataSet&gt;
  </code></pre>
  
  <p>It is not taking CustomerID, So the insertion is not working. Why the DataTable does not show the Null values in the Column fields and How to pass if the DataTable containing null value as a XML?
  Please any suggestions.</p>