How to create a XML file using XDocument and LINQ in C#?
<p>I have a three List in c# ,the variable names are l_lstData1,l_lstData2,l_lstData3</p>

<p>The File Structure is</p>

<pre><code> &lt;FileDetails&gt;
 &lt;Date FileModified="29/04/2010 12:34:02" /&gt; 
 &lt;Data Name="Data_1" DataList="India" Level="2" /&gt; 
 &lt;Data Name="Data_2" DataList="chennai" Level="2" /&gt; 
 &lt;Data Name="Data_3" DataList="hyderabad" Level="2" /&gt; 
 &lt;Data Name="Data_4" DataList="calcutta" Level="2" /&gt; 
 &lt;Data Name="Data_5" DataList="vijayawada" Level="1" /&gt; 
 &lt;Data Name="Data_6" DataList="cochin" Level="1" /&gt; 
 &lt;Data Name="Data_7" DataList="madurai" Level="0" /&gt; 
 &lt;Data Name="Data_8" DataList="trichy" Level="0" /&gt; 
 &lt;/FileDetails&gt;
</code></pre>

<p>The Values od 3 Lists are as follows :</p>

<pre><code>  l_lstData1[0] = "India";l_lstData1[1] = "chennai";l_lstData1[2] = "hyderabad";
  l_lstData1[3] = "calcutta"; 
</code></pre>

<p>so the level attribute of the above XML(element : Data) has tha value = "2".</p>

<pre><code>  l_lstData2[0] = "vijayawada";l_lstData2[1] = "cochin";      
</code></pre>

<p>so the level attribute of the above XML(element : Data) has tha value = "1".</p>

<pre><code> l_lstData3[0] = "madurai";l_lstData3[1] = "trichy";      
</code></pre>

<p>so the level attribute of the above XML(element : Data) has tha value = "0".</p>

<p>How can i create the XML using Xdocument and also using LINQ....Plz revert back me if u have any queries</p>
