title: How to create rtf using xml xslt and c#
body: <p>I have created an xml document and an xslt document and now i want to create a word doc/rtf using these through using c#. </p>
  
  <p>I have found the following code on the internet however I can't find a way to use it because I'm not using datasets. I just want the program to read the xml and the xslt combine the two and create a word document</p>
  
  <p>Any help would be really appreciated</p>
  
  <pre><code>DataSet ds;
  
      XmlDataDocument xmlDoc;
  
      XslCompiledTransform xslTran;
  
      XmlElement root;
  
      XPathNavigator nav;
  
      XmlTextWriter writer;
  
      try
  
      {
  
          //Create the DataSet from the XML file
  
          ds = new DataSet();
  
          ds.ReadXml("Employee.xml");
  
          //Create the XML from the DataSet
  
          xmlDoc = new XmlDataDocument(ds);
  
          //Load the XSLT for Transformation
  
          xslTran = new XslCompiledTransform();
  
          xslTran.Load("Employee.xslt");
  
          //Determine the Root object in the XML
  
          root = xmlDoc.DocumentElement;
  
          //Create the XPath Navigator to navigate throuth the XML
  
          nav = root.CreateNavigator();
  
          //First delete the RTF, if already exist
  
          if (File.Exists("Employee.rtf"))
  
         {
  
              File.Delete("Employee.rtf");
  
         }
  
          //Create the RTF by Transforming the XML and XSLT
  
          writer = new XmlTextWriter("Employee.rtf", System.Text.Encoding.Default);
  
          xslTran.Transform(nav, writer);
  
          //Close the Writer after Transformation
  
          writer.Close();
  
          //Release all objects
  
          writer = null;
  
          nav = null;
  
          root = null;
  
          xmlDoc = null;
  
          ds = null;
  
          MessageBox.Show("Document created successfully.....");
  
      }
  
      catch (Exception ex)
  
      {
  
          writer = null;
  
          nav = null;
  
          root = null;
  
          xmlDoc = null;
  
          ds = null;
  
          MessageBox.Show(ex.StackTrace);
  
      }
  
  }
  </code></pre>