Chuyển File Word Sang Xml – download Chuyển Đổi Word Sang Xml

Basic Knowledge about Office OpenXML

When talking about Office OpenXML, we may think of HTML. Actually, Office OpenXML is similar to HTML both are tag-based languages. The difference between Office OpenXML and HTML is that the tags which Office OpenXML uses are not predefined. If we want to create own tags within Office OpenXML, we need to follow a few rules.

Đang xem: Chuyển file word sang xml

Firstly, only one root element is contained in Office OpenXML document. The root element is often taken as document element and appears after the prolog section. Besides, all the Office OpenXML elements should contain end tags. Both start and end tag should be identical. Also, the elements can’t overlap. What’s more, all attribute values must use quotation marks and we can’t use some special characters within the text. After following the rules, the Office OpenXML document will be well formatted.

Use C# and VB.NET Convert Doc to Office OpenXML via Spire.Doc

Spire.Doc (Spire.Office) presents you an easy way to convert Doc to Office OpenXML. In this way, we can convert an exist Word doc file to Office OpenXML format with a few clicks. Now, just follow the simple steps.

Step 1: Create Project

download Spire.Doc and install on system. Create a project through Visual Studio and add Spire.Doc DLL as reference.

Xem thêm: Tắt Đồng Bộ Icloud Ios 12 ? Hướng Dẫn Cách Tắt Sao Lưu Icloud Tự Động

Note: Please make sure Spire.Doc and Visual Studio are correctly installed on system

Step 2: Load Word Doc File

Load local Word doc file which we need to convert to Office OpenXML format. The following code can help us load it.

Document document = new Document();document.LoadFromFile(
Step 3: Convert Doc to Office OpenXML

Spire.Doc supports convert Word Doc files to most of popular file formats such as PDF, HTML, Office OpenXML, EPub, RTF, Dot, Text, etc. Now, use the code below to convert Word to Office OpenXML.

document.SaveToFile(“Sample.xml”, FileFormat.Xml);
Step 4: Full Code

Now, write the full code into your project and press F5 to start the program.

Xem thêm: Phần Mềm Chuyển File Ảnh Sang Excel (Có Thể Chỉnh Sửa Bằng Ocr)

Imports SystemImports System.Windows.FormsImports Spire.DocImports Spire.Doc.DocumentsNamespace to XMLPartial Public Class Form1Inherits FormPublic Sub New()InitializeComponent()End SubPrivate Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)”Create word documentDim document As New Document()document.LoadFromFile(“D:Sample.doc”)”Save doc file.document.SaveToFile(“Sample.xml”, FileFormat.Xml);”Launching the MS Word file.WordDocViewer(“Sample.xml”)End SubPrivate Sub WordDocViewer(ByVal fileName As String)TrySystem.Diagnostics.Process.Start(fileName)CatchEnd TryEnd SubEnd ClassEnd Namespace
After running the demo, you may find an Office OpenXML document launched on your browser:


Spire.Doc is an MS Word component which enables user to perform a wide range of Word document processing tasks directly, such as generate, read, write and modify Word document for .NET and Silverlight. Click to Learn more…

Xem thêm bài viết thuộc chuyên mục: Chuyển file

Khuyễn Mãi Hot