Repair a Word Document With a Premature End of Data XML Error
Question details
Recover a Word document that reports a premature end of data XML parsing error.

- Product
- Microsoft Word
- Device & OS
- not provided
- Scenario
- Opening a Word document that contains images and captions.
- Observed behavior
- Word reports an XML parsing error: “Premature end of data in tag document, line 2.” The issue was not apparent from reviewing the indicated lines.
Locate the affected document and check whether it is stored in OneDrive or another service with version history. If Word can open a recovered copy, identify any grouped or floating images that may need their layouts recreated.
Open and Repair the Word Document, Then Simplify Image Layouts
Try Word’s repair command first, then adjust image layouts if the document opens.
In the reported case, the document was recovered after its image layouts were changed. Floating or grouped images may contribute to corruption, but they are not the cause of every XML parsing error.
In Word, select File > Open > Browse and select the affected document. Click the arrow next to Open, then choose Open and Repair.
If the document opens, select File > Save As and save the recovered content under a new name.
Select each floating image, open Layout Options, and choose In Line with Text. If images are grouped, ungroup them first using Picture Format > Group > Ungroup.
Use Insert > Table to create cells for images that need to appear together, then place the images in the cells and set them to In Line with Text.
Select an image and choose References > Insert Caption. Add the appropriate caption, then save and reopen the document to check it.

Restore an Earlier Version From OneDrive
Use version history if the document was saved to OneDrive before it became corrupted.
Edit Recovered Word Documents With WPS Office
WPS Office is a free, lightweight Office alternative with a familiar interface for opening and editing compatible documents. Move a recovered Word file to WPS Writer for continued work; WPS is not a guaranteed fix for Word’s XML corruption error.

Frequently Asked Questions
What does “Premature end of data” mean in a Word document?
It means Word encountered incomplete or malformed XML while reading the document. The reported line does not always make the underlying cause obvious.
Where is Open and Repair in Word?
Select File > Open > Browse, choose the document, and click the arrow next to Open. Select Open and Repair from the menu.
Can images cause this XML error?
Image layout corruption may contribute to this error. In the reported case, the recovered document used inline images and table cells instead of grouped image layouts, but other causes are possible.
What can I do if Word cannot repair the document?
If the file is in OneDrive, open its More options menu and select Version history to look for an earlier usable version. Recovery depends on an earlier version being available.




