Dynamically create text file from xml/text file
<p>Can I dynamically create a text file from a c# program, using data from a previously created xml file and text file, I have written half the code, but can't go any further. Please help</p>

<pre><code>using System;
using System.IO;
using System.Xml;

namespace Task3
{

   class TextFileReader
   {

      static void Main(string[] args)
      {
         String strn=" ", strsn=String.Empty;  
         XmlTextReader reader = new XmlTextReader("my.xml");

                 while (reader.Read())
                 {
                    switch (reader.NodeType)
                    {
                       case XmlNodeType.Element: // The node is an element.
                          if (reader.HasAttributes)
                          {
                             strn = reader.GetAttribute(0);
                             strsn = reader.GetAttribute(1);
                             int counter = 0;
                             string line;
                             // Read the file and display it line by line.
                             System.IO.StreamReader file = new System.IO.StreamReader("read_file.txt");
                             string ch, ch1;
                             while ((line = file.ReadLine()) != null)
                             {
                                if (line.Substring(0, 1).Equals("%"))
                                {
                                   int a = line.IndexOf('%');
                                   int b = line.LastIndexOf('%');
                                   ch = line.Substring(a + 1, b - 1);
                                   ch1 = line.Substring(a, b+1);
                                   if (ch == "name")
                                   {
                                      string test = line.Replace(ch1, strn);
                                      Console.WriteLine(test);
                                   }
                                   else if (ch == "sirname")
                                   {
                                      string test = line.Replace(ch1, strsn);
                                      Console.WriteLine(test);
                                   }
                                }
                                else
                                {
                                   Console.WriteLine(line);
                                }
                                counter++;
                             }
                             file.Close();
                          }
                          break;
                    }

                 }        

         // Suspend the screen.
         Console.ReadLine();
      }
   }
}
</code></pre>

<p>The xml file from which I am reading is:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; 
&lt;Workflow&gt;
  &lt;User UserName="pqr" Sirname="sbd" /&gt; 
  &lt;User UserName="abc" Sirname="xyz" /&gt; 
&lt;/Workflow&gt;
</code></pre>

<p>And the text file is:</p>

<pre><code>hi this is me
%sirname%
%name%
</code></pre>

<p>But this is not what I want..please help</p>
