title: Read XML file to an already existing database table
body: <p>I'm trying to read an XML-file into a database table that already exists. </p>
  
  <p>The problem is that the XML-tags and the database columns doesn't have the same name although they have the same datatype. Therefore I'd like to "translate" the XML-tags into the database columns so that the the input to the database becomes possible. 
  I'm not sure how to do that however.</p>
  
  <p>Here is what I've done so far.</p>
  
  <pre><code> static void writeToDatabase()
          {
              XmlDocument doc= new XmlDocument();
              try {
                  //Reading the xml
                    doc.Load("C:\\Temp\navetout.xml");
  
  
                   DataTable dt = new DataTable();
  
                 //Code here to read the xml into an already existing database table?
  
  
  
                  } 
  
              catch (Exception e) 
              {
                  Console.WriteLine(e.Message);
              }
  
          }
  </code></pre>
  
  <p>The database is located on another server, I've included this on the <code>app.config</code></p>
  
  <pre><code> &lt;connectionStrings&gt;
      &lt;add name="CS"
      connectionString="Data Source=tsrv2062;Initial Catalog=BUMS;Integrated Security=True"/&gt;
    &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>Let's say for an example that the XML file has the tags "<em>Name</em>" while the database table column has the column "<em>Firstname</em>".</p>
  
  <p>Before reading the the XML data into the database table, I suppose the XML-tags has to be translated into the Database table column. In this case "<em>Firstname</em>".</p>
  
  <p>Can anyone help me out with this "translation" and the reading into the database table.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>XML example:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ArrayOfFolkbokforingspostTYPE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
    &lt;FolkbokforingspostTYPE&gt;
      &lt;Sekretessmarkering xsi:nil="true" /&gt;
      &lt;Personpost&gt;
        &lt;PersonId&gt;
          &lt;PersonNr&gt;7527245452542&lt;/PersonNr&gt;
        &lt;/PersonId&gt;
        &lt;HanvisningsPersonNr xsi:nil="true" /&gt;
        &lt;Namn&gt;
          &lt;Tilltalsnamnsmarkering&gt;20&lt;/Tilltalsnamnsmarkering&gt;
          &lt;Fornamn&gt;skjdgnsdng&lt;/Fornamn&gt;
          &lt;Mellannamn xsi:nil="true" /&gt;
          &lt;Efternamn&gt;sdsdgsdgs&lt;/Efternamn&gt;
          &lt;Aviseringsnamn xsi:nil="true" /&gt;
        &lt;/Namn&gt;
        &lt;Folkbokforing&gt;
          &lt;Folkbokforingsdatum&gt;20060512&lt;/Folkbokforingsdatum&gt;
          &lt;LanKod&gt;56&lt;/LanKod&gt;
          &lt;KommunKod&gt;77&lt;/KommunKod&gt;
          &lt;ForsamlingKod xsi:nil="true" /&gt;
          &lt;Fastighetsbeteckning&gt;PÅLNGE 6:38&lt;/Fastighetsbeteckning&gt;
          &lt;FiktivtNr&gt;0&lt;/FiktivtNr&gt;
        &lt;/Folkbokforing&gt;
        &lt;Adresser&gt;
          &lt;Folkbokforingsadress&gt;
            &lt;CareOf xsi:nil="true" /&gt;
            &lt;Utdelningsadress1 xsi:nil="true" /&gt;
            &lt;Utdelningsadress2&gt;sgdsdgsdgs&lt;/Utdelningsadress2&gt;
            &lt;PostNr&gt;78965&lt;/PostNr&gt;
            &lt;Postort&gt;PÅLÄNG&lt;/Postort&gt;
          &lt;/Folkbokforingsadress&gt;
          &lt;Riksnycklar&gt;
            &lt;FastighetsId&gt;46464545&lt;/FastighetsId&gt;
            &lt;AdressplatsId&gt;764846846&lt;/AdressplatsId&gt;
            &lt;LagenhetsId&gt;45465654645&lt;/LagenhetsId&gt;
          &lt;/Riksnycklar&gt;
        &lt;/Adresser&gt;
        &lt;Fodelse&gt;
          &lt;HemortSverige&gt;
            &lt;FodelselanKod&gt;00&lt;/FodelselanKod&gt;
            &lt;Fodelseforsamling&gt;NEDERKALIX&lt;/Fodelseforsamling&gt;
          &lt;/HemortSverige&gt;
        &lt;/Fodelse&gt;
        &lt;Medborgarskap&gt;
          &lt;MedborgarskapslandKod&gt;SE&lt;/MedborgarskapslandKod&gt;
          &lt;Medborgarskapsdatum&gt;0&lt;/Medborgarskapsdatum&gt;
        &lt;/Medborgarskap&gt;
      &lt;/Personpost&gt;
    &lt;/FolkbokforingspostTYPE&gt;
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>These are the columns of the database table: </p>
  
  <pre><code>PersonalIdentityNumber
  ProtectedIdentity
  ReferedCivicRegistrationNumber
  UnregistrationReason
  UnregistrationDate
  MessageComputerComputer
  GivenNameNumber
  FirstName
  MiddleName
  LastName
  NotifyName
  NationalRegistrationDate
  NationalRegistrationCountyCode
  NationalRegistrationMunicipalityCode
  NationalRegistrationCoAddress
  NationalRegistrationDistributionAddress1
  NationalRegistrationDistributionAddress2
  NationalRegistrationPostCode
  NationalRegistrationCity
  NationalRegistrationNotifyDistributionAddress
  NationalRegistrationNotifyPostCode
  NationalRegistrationNotifyCity
  ForeignDistrubtionAddress1
  ForeignDistrubtionAddress2
  ForeignDistrubtionAddress3
  ForeignDistrubtionCountry
  ForeignDate
  BirthCountyCode
  BirthParish
  ForeignBirthCity
  CitizenshipCode
  CitizenshipDate
  Email
  Telephone
  Mobiletelephone
  Gender
  NotNewsPaper
  Note
  StatusCode
  NationalRegistrationCode
  RegistrationDate
  LastUpdatedFromNavet
  TemporaryDistrubtionAddress1
  TemporaryDistrubtionAddress2
  TemporaryDistrubtionAddress3
  TemporaryDistrubtionCountry
  Password
  VisibilityLevel
  LastChangedBy
  LastChangedDate
  SeamanIdentity
  Category
  </code></pre>
  
  <p>Here for an example, the <code>&lt;PersonNr&gt;</code> tagg and the databse column <code>PersonalIdentityNumber</code> are the same.
  The column that doesn't match with the XML-tags are supposed to returning <code>null</code>.</p>