Question

I parse document.xml(change file.docx name to file.docx.zip and uznip it) file manually and put my code:

<w:r>
      <w:t>new text</w:t> 
</w:r>

instead of

<w:r>
      <w:t>text</w:t> 
</w:r>

and then I save it into zip-archieve(and change file.docx.zip name to file.docx) and try to open docx with MSWord 2013. But I get error by Word - incorrect document. How to fix it ? Thank you.

Était-ce utile?

La solution

Why are you doing it manually? I used the Open XML SDK and it worked smoothly.

You have basically access to the whole xml tree so you can change almost anything you want, with the exception that the library takes care of zipping and unzipping.

The SDK has also a viewer where you can have a better look at the file, and what I've found is that most docx documents have internally multiple files zipped together. Maybe you are missing one of them.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top