Error: SAXException: [word/document.xml line 2]: Opening and ending tag mismatch: hyperlink line 0 and p

Hello everybody, could someone please help? I cannot load my document fully, the error is "An error occurred during opening the file. This may be caused by incorrect file contents.
The error details are:
“SAXException: [word/document.xml line 2]: Opening and ending tag mismatch: hyperlink line 0 and p”
Please help!!!
Acosta, Acosta y Ladio-vistoJMA-Res-Disc.docx (89.2 KB)

Hi everyone,

I have this same problem, and I cannot fix it. Could anybody help, please?

The error details are:
“SAXException: [word/document.xml line 2]: Opening and ending tag mismatch: sdtContent line 2 and del”

I have tried to fix it myself, but I am afraid this is beyond my ability.

Acosta, Acosta y Ladio-vistoJMA-Res-Disc.docx (89.0 KB)

1 Like

Dear Mikekaganski, thanks a lot!!! You saved me!!!

what was the problem? I inspected the document.xml in gvim and the file was complete…
could you be so kind to explain it to me?

Thank you so, so much!!!

The problem was LibreOffice (of a very old version) writing an XML element’s closing tag out of order. Moving the tag to the proper place fixed this.

1 Like

Dear Mike,

If it’s not too much to ask, would you mind deleting the download link to the document now? The document includes the work of several people and I wouldn’t want to infringe on anyone’s authors’ rights. Again, thank you so much. You have really saved my day!

I have installed Version: 6.1.5.2… will installing version 7.6 solve this problem?

I hope so. Unfortunately, the support of change tracking in DOCX (a highly complex topic) is imperfect, and the constant flow of similar (not same) errors shows that, fixing some bugs, new emerge; but of course, one always needs to use native file format (ODF in case of LibreOffice) when saving documents; and only export to external file formats (like DOCX) when already having native file saved.

1 Like

Thanks a lot for your time in explanations and file corrections!!

All the best!!!

No. If you output malformed xml, with tags messed up, the problem can’t be DOCX; it may only be due to a buggy xml library that you are using, or to hacky code that here and there directly deals with the xml data as a raw text string and not using a dedicated library. Given the number of similar errors that are popping up over time, it seems more the second option.

“No” what? Do you answer to voices in your head? I never claimed it’s DOCX’ fault; if you take some (not too huge) effort and try to read, you will see that I talk about problems in supporting the external file format - i.e., the problems are in the supporting code (our).

And e.g. there is “The problem was LibreOffice (of a very old version) writing an XML element’s closing tag out of order”, that I wrote in 2023. But well, reading is hard.

The same problem just happened to me with Libreoffice 7.3.7.2. with a recent DOCX file; I had to move a couple of tags that had been put in the wrong order. And it seems I’m not the only one experiencing these problems, given the number of results I got when I googled the error.

So while I understand that supporting DOCX in general, and DOCX revision in particular, is a thankless task (and I really thank you for that), I can’t see how this may be related to putting xml tags in the wrong order, unless the xml document is not handled as an object through a library, but as raw text.

… and … ? Yes we write it as text; and we use some helpers, but not a “library” (as opposed to when we read it). What is that you are trying to say by that? That it’s easy to just re-write it all using some library, and magically have it OK? Patches welcome.

BTW, I’ll try to switch to v.24.x (I’m on Ubuntu 22.04 which still has 7.3). Has xml handling been improved in the new version?

so it’s a design problem as opposed to a contingent one, therefore such kind of problems are likely to resurface again and again in many different corner cases that are difficult to predict, and are not easily debuggable by those who do not intimately know the code. In this context, “patches welcome” is a bit out of context. Only a complete refactoring would help, but I imagine that it would require a substantial effort. Has there been any discussion about that in the core dev team?

The same problem happened to me a number of times. Oftentimes, the problem being a malformed XML and OOXML being a shitty familiy of XML, that required a lot of pain debugging to recover a huge amount of work (usually this happens with complex documents and lots of edits).

Working in ODF and only finally saving in DOCX is a non starter in many contexts, especially when you have multiple revisions of the same file exchanged between different people. The ability to seamlessly work with documents originally in DOCX is one of the most important factors in using Libreoffice – for me probably one of the few reasons why I still use it.

@mikekaganski good afternoon. Plis, which closing tag you move? from where to? I have a same problem and i see you correcting the error in many questions/issues. Unfortunately, i can’t send the file because privacy questions. How i resolve this? Tks