XML(Extensible Markup Language) is one kind of source language which allows users to define own markup language. It can make marked electronic files have structure, mark data and define data type. Also, it offers only one method to describe and exchange structural data which is independent of application.
Although XML can be used to save data, it is much different from database. Database is powerful on data storage and analytics, while XML just displays data. Actually, XML is very simple so that it can be easily used to read and write data in any applications. Also, it becomes the most frequently used language to exchange data.
Sometimes, in order to deliver data information through internet, people may convert Word document to XML. In this post, I will introduce a method to convert Word to XML with C#/VB.NET quickly and easily.
I used Spire.Doc for .NET, a .NET Word component specializing in manipulate Word document in my example. Therefore, I add its dll file as reference in my project.
Detailed Steps Shown as Following:
I. Load Word document which I want to convert to xml by using document.LoadFromFile() method. Parameter passed to this method is file name string.
Document document = new Document();
Dim document As New Document()
II. Convert Word document to XML file by using document.SaveToFile() method. Two parameters are passed to this method, string file name and file format.
III. Launch this file and debug this program to get converted xml file.
Note: Word document I convert in this example is DOCX file. You can also convert DOC file to xml following the above step by changing file name string in document.LoadFromFile() method.
Result Shown as Following: