I was able to create a Word Document with content controls mapped to an Xml schema and using the code from this blog: http://seroter.wordpress.com/2009/12/23/populating-word-2007-templates-through-open-xml/ I am able to insert data into the word document.
The question I have is, is it possible to replace the the code below so that I can use an Xml file instead of having to write this for each finding:
//create XML string matching schema custom XML path
string newXml = "<root>" +
"<FINDING>Adobe Flash Player contains multiple...</FINDING>" +
"<STATUS>Open</STATUS>" +
"<THREATLEVEL>High</THREATLEVEL>" +
"<RECOMMENDATION>Update Flash Player to version...</RECOMMENDATION>" +
"<DEVICEAFFECTED>UserPC</DEVICEAFFECTED>" +
"<SCANNER>XXXXXX</SCANNER>" +
"</root>";
I have tried replacing this with: string newXml = @"C:\Users\Christopher\Desktop\BookData\TestReport.xml"; and created a nested using statement with StreamReader and the existing StreamWriter but the word document would not populate and there would not be any errors.
--I just tried to replace that code with this: //create XML string matching schema custom XML path string newXml = @"C:\Users\Christopher\Desktop\BookData\TestReport.xml"; using (StreamReader sr = new StreamReader (newXml)) { newXml = sr.ReadToEnd(); }
and I no longer get the error when I open the document, but the content controls are not populating?
Thank you.