Code Snippet posted by:
Megan00 | Posted on: 9/17/2012 | Category:
C# Codes | Views: 594 | Status:
[Member] |
Points: 40
|
Alert Moderator
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);
}
}
}
Never give up! Smile to the world!
http://excelcsharp.blog.com/