Thursday, May 01, 2014

Two Tools for Fixing Word the DOCX Error: "The name in the end tag of the element must match the element type in the start tag"

These two links are for free tools for fixing a subset of the Word DOCX error, "The name in the end tag of the element must match the element type in the start tag". The subset of the errors occur when a  <m:oMath> tag gets in the wrong order. Tony Jollans' Rebuilder may fix a different math tag order issue than the Mr. Fixit.

Tony Jollan's tool might fix this tags in this order, see here:

          Start of equation
        Probably some graphics
          End of equation

The Mr. Fixit tool seems to fix math tag order issues of this variety. See here:

<mc:Choice Requires=”wps”>

There are other causes of the "The name in the end tag of the element must match the element type in the start tag" error. For instances, one file I found out started out with a 'w:t' tag not having a closing tag. Another  one starts with 'w:tr' tag not having a closing one. I also have a lot of files where the problem starts with a missing 'mc:Fallback' tag. I am trying to work on a general solution with my freeware Savvy DOCX Recovery program. I will announce the update in this blog. [Edit: I just found this post which looks like the best description of how to fix the issue: XML Marker appears to be the easiest tool to use to fix things. You can use any XML editor or even Excel to find where the error lies and then use NotePad++ to fix things, but NotePad++ is slow with large document.xml files you sometimes get for instance with somebody's thesis].

Suffice it to say the approach I'm taking in VB.Net that I'm using to code Savvy DOCX, is to read the word\document.xml subfile within the DOCX with the VB.Net System.XML reader and examine the detailed errors that arise. The errors go beyond what is remarked upon in the Word opening errors and tell you where and which kind of ending tag is missing. I then add the correct ending tag and read the file again. Often the loop will need to be repeated several times. Also note, I'm using a method of pinpointing the errors in the XML by first treating the document.xml subfile so that each tag is on it's own line, a strategy I think I learned here.

Instead of using VB.Net, you can of course do this manually. To do put each tag on it's own line manually, I use NotePad++ and then do a replace of "><" with ">\r\n<" in the XML. The "\r\n" makes new lines between the tag but the trick to get NotePad++ to interpret the characters as new line commands is not to use normal replace but move the radio button in the Replace app's lower left corner to "Extended."

To be able to get the same level of detail regarding the XML errors as System.XML gives you in VB.Net, you can use the Microsoft freeware XML Notepad.

So if you use the above techniques with some of the other techniques I have discussed in my article Secrets of Recovering Corrupt Word DOCX Files, for repairing zip corruption if there is any and for getting the best extraction of the document.xml file that is usually the cause of corruption, I think you can usually fix your issue manually. 

You can upload files to me for recovery here: I say on my site that I charge $22 but that is only for satisfactory recovery. If I can't can't recover your file then, my work is free, although a donation will be be most welcome :-). There are 3 or 4 regular Word MVP's who will fix your file for free. See herehere and here (thread may no longer be monitored) .


BethW said...

Hi do you still recover files?

Paul D Pruitt said...

Yes. You can send files to I charge $5 for the file analysis and if your file is recoverable, I charge an additional $17.

Hasleo Data Recovery FreeV3.2 - Free as in Freeware - Permanently from Hasleo Software "Hasleo Data Recovery FreeV3.2 100% Free Data Recovery Software...