Yet Another Cycling Forum

General Category => The Knowledge => Ctrl-Alt-Del => Topic started by: Gattopardo on 05 November, 2018, 09:58:51 pm

Title: Help with correcting an xml file
Post by: Gattopardo 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?
Title: Re: Help with correcting an xml file
Post by: fuaran 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.
Title: Re: Help with correcting an xml file
Post by: Gattopardo on 05 November, 2018, 10:35:59 pm
Too big for pastebin  ::-)
Title: Re: Help with correcting an xml file
Post by: Jaded on 05 November, 2018, 10:45:11 pm
All Tags have to have end tags. This (https://www.w3schools.com/xml/xml_syntax.asp) 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
Title: Re: Help with correcting an xml file
Post by: Gattopardo on 05 November, 2018, 11:10:51 pm
All Tags have to have end tags. This (https://www.w3schools.com/xml/xml_syntax.asp) 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.
Title: Re: Help with correcting an xml file
Post by: Gattopardo 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

Title: Re: Help with correcting an xml file
Post by: Gattopardo 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.
Title: Re: Help with correcting an xml file
Post by: Ham on 06 November, 2018, 12:24:21 pm
Would expat help? https://libexpat.github.io/
Title: Re: Help with correcting an xml file
Post by: philip 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.
Title: Re: Help with correcting an xml file
Post by: Gattopardo 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?
Title: Re: Help with correcting an xml file
Post by: vorsprung on 06 November, 2018, 02:32:56 pm
had a go but couldn't get it to disentangle, sorry
Title: Re: Help with correcting an xml file
Post by: Phil W 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