Author Topic: Help with correcting an xml file  (Read 1953 times)

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Help with correcting an xml file
« on: 05 November, 2018, 09:58:51 pm »
Hello and help,

Have a docx file, opened in libraoffice and something was edited and now the file does not open in libra office but gives the reason
File format error found at
SAXParseException: '[word/document.xml line 2]: Opening and ending tag mismatch: inline line 0 and anchor
', Stream 'word/document.xml', Line 2, Column 29565(row,col).


Searching shows the problem to be in the xml file but can't seem to workout what and where the error is so I can correct the xml file so the document can be opened.

How can I link to a text file?

fuaran

  • rothair gasta
Re: Help with correcting an xml file
« Reply #1 on: 05 November, 2018, 10:15:59 pm »
How can I link to a text file?
Pastebin. https://pastebin.com/

Viewing the XML in an editor with syntax highlighting can be helpful for spotting errors.

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: Help with correcting an xml file
« Reply #2 on: 05 November, 2018, 10:35:59 pm »
Too big for pastebin  ::-)

Jaded

  • The Codfather
  • Formerly known as Jaded
Re: Help with correcting an xml file
« Reply #3 on: 05 November, 2018, 10:45:11 pm »
All Tags have to have end tags. This might help.


It sounds like there's a mistyped end tag. As Furan says, using an editor that formats the document highlighting tags is a good start. https://en.wikipedia.org/wiki/Comparison_of_XML_editors
It is simpler than it looks.

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: Help with correcting an xml file
« Reply #4 on: 05 November, 2018, 11:10:51 pm »
All Tags have to have end tags. This might help.


It sounds like there's a mistyped end tag. As Furan says, using an editor that formats the document highlighting tags is a good start. https://en.wikipedia.org/wiki/Comparison_of_XML_editors

Than you, downloaded exchanger xml and has pin pointed the fault line.

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: Help with correcting an xml file
« Reply #5 on: 05 November, 2018, 11:49:24 pm »
Ok the link is here, anyone fancy a go at sorting it as I can not get my head around it.

https://www.dropbox.com/s/tz86ys1ofqjiuzw/document.xml?dl=0


Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: Help with correcting an xml file
« Reply #6 on: 06 November, 2018, 11:54:48 am »
There are many more errors in the xml file, and can't understand how it has been corrupted.  The file is part of an .docx document.

Trying to find a an xml editor that doesn't have the file in one line so I can work out what to edit as I don't think in lines.

Re: Help with correcting an xml file
« Reply #7 on: 06 November, 2018, 12:24:21 pm »
Would expat help? https://libexpat.github.io/

Re: Help with correcting an xml file
« Reply #8 on: 06 November, 2018, 01:11:48 pm »
On Linux (and perhaps Windows as well) you can use:

xmllint --recover somefile.xml > new.xml

to output valid XML from a broken XML file, it works by discarding the problem bits and retaining the bits that parse correctly. Use

xmllint --recover --format somefile.xml > new.xml

if you want "pretty" formating.

Gattopardo

  • Lord of the sith
  • Overseaing the building of the death star
Re: Help with correcting an xml file
« Reply #9 on: 06 November, 2018, 02:31:28 pm »
On Linux (and perhaps Windows as well) you can use:

xmllint --recover somefile.xml > new.xml

to output valid XML from a broken XML file, it works by discarding the problem bits and retaining the bits that parse correctly. Use

xmllint --recover --format somefile.xml > new.xml

if you want "pretty" formating.

Unfortunatly no linux laptop to hand, is there a way to do it in windows?

vorsprung

  • Opposites Attract
    • Audaxing
Re: Help with correcting an xml file
« Reply #10 on: 06 November, 2018, 02:32:56 pm »
had a go but couldn't get it to disentangle, sorry

Phil W

Re: Help with correcting an xml file
« Reply #11 on: 06 November, 2018, 02:52:07 pm »
I have fixed the incorrect closing tags using my code editor but whether it will open in Open Office I do not know. The XML is Open Office by the way not docx format.

There were a couple of opening wp:inline tags with closing wp:anchor tags by the way.  File in attached Dropbox link.

https://www.dropbox.com/s/tcpxbssxrc2its9/document.xml?dl=1