I have a question on how to save an xmldoc as a word file. I want to open the word file, do some manipulation on the undelying xml structure using the xmldocument class and then resave it back to the word file. This is what im currently doing:
using (WordprocessingDocument wordDoc = WordprocessingDocument.Open(@"E:\HelloWorld.docx", true))
{
MainDocumentPart mainPart = wordDoc.MainDocumentPart;
var xmlDoc = new XmlDocument();
using (Stream partStream = part.GetStream())
using (XmlReader partXmlReader = XmlReader.Create(partStream))
xmlDoc.Load(partXmlReader);
//xml node manipulation here
xmlDoc.Save(@"E:\HelloWorld.docx");
}
This results in a corrupt document however. What is the proper way to do this functionality?