Page 1 of 1

Extracing 'word/document.xml' from docx and saving

PostPosted: Tue Nov 11, 2008 4:47 pm
by seaster8
Hello,
I am trying to figure out how to extract 'word/document.xml' from a docx file and then saving that xml to a file. I've got the extracting done using "MainDocumentPart", but am having difficulties figuring out how to then save that to a file. I have looked throughout the site and documentation and cannot for the life of me figure that part out. Anybody have any suggestions?

Thank you.

Re: Extracing 'word/document.xml' from docx and saving

PostPosted: Tue Nov 11, 2008 9:49 pm
by jason
See org/docx4j/samples/DisplayMainDocumentPartXml.java

You can use marshaltoString(wmlDocumentEl, true, true) if you want to pretty print.

The XMLUtils class also contains other convenience methods, for example to marshal to an input stream, or DOM document.

cheers

Jason