title: Create write and save xml file dynamically in c# .net
body: <p>I want to <strong>create xml file and write data from database</strong> in it. file will be created dynamically. </p>
  
  <p>I am storing data in DataTable. Query is <code>select documentId,documentContent from tblDocument where status = 'F'</code></p>
  
  <p>where <strong>documentContent</strong> is xml data.</p>
  
  <p>I have tried following code but its not working,</p>
  
  <pre><code>foreach(DataRow dr in dt.Rows)
  {
      string filepath =  ConfigurationManager.Appsetings[Constants.FailedDocuments];
      string filename = "message_"+ dr["documentId"].ToString();
      string content = dr["documentContent"].ToString();
      XDocument xdoc = new XDocument();
      xdoc.parse(content);
      xdoc.Load(filepath+filename);
  }
  </code></pre>
  
  <p>I am new to this and don't know how to and where to place this code correctly as i want to write <code>content</code></p>