I am having a XML file generated in run time on my program.This XMLfile.InnerText() is having some formats(Like -enter,spaces,tab,Alignments) as below,
This a test of the windows driver
2115 -XXXXXXXXXX BRANCHXXXX
XXXXXXXXXX XXXXXXXXXX
XXXXXXXXXX XX XXXXXXXXXX : 08/23/16
XXX XXX: 08/23/16
XXXXXXXX XXXXXX : 9
------------------------------------------------------------------
XXXXXX XXX X XXXX:
XXX 0,01
XXXXXX XXX XXXXX:
1 XXXXXXXXX
------------------------------------------------------------------
I am trying create a word document with this XMLfile.InnerText(with this above format& alignments) using VB.net(provided the used code as example).
By using Microsoft.Office.Interop.Word.Application -> Range.InsertXML() method i am able to bring this same format in the word file.
But How to capture the same XML format in my newly created word file by using OpenXML method?
What I have tried:
Dim vWordDoc As WordprocessingDocument = WordprocessingDocument.Create(tmppath, WordprocessingDocumentType.Document)
' Set the content of the document so that Word can open it.
Dim vMainPart As MainDocumentPart = vWordDoc.AddMainDocumentPart()
' Create the document structure and add some text.
vMainPart.Document = New Document()
Dim vBody As Body = vMainPart.Document.AppendChild(New Body())
Dim vPara As Paragraph = vBody.AppendChild(New Paragraph())
Dim run As Run = vPara.AppendChild(New Run())
run.AppendChild(New Text(XMLFile.InnerText))
vMainPart.Document.Save()
vWordDoc.Close()