Convert XML to Word with C#

Posted by Megan00 under C# category on | Points: 40 | Views : 6061
XML to Word can be realized by three lines' of code in this section with C# via a .NET Word component. First, you need to create a new document and then, call two methods in Spire.Doc dll, one is to load an XML from system by calling the method public void LoadFromFile(string fileName, FileFormat fileFormat) , the other is to save this xml file as word by using public void SaveToFile(string fileName, FileFormat fileForma t). Please follow below code to accomplish your xml to word task :

C# for XML to Doc/Docx:

using Spire.Doc;
using Spire.Doc.Documents;

namespace xml_to_word
class Program
static void Main(string[] args)
Document doc = new Document();
doc.LoadFromFile(@"D:\michelle\my file\xml to word.xml", FileFormat.Xml);
doc.SaveToFile("xml to word.doc", FileFormat.Doc);

Comments or Responses

Login to post response