richardlehane / xmltool

command line tool for cleaning up XML files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cleans up generic XML files generated by databases. Also audits xml files, counting occurrence of elements. If given a directory, will do a recursive walk, fixing or auditing any files with a ".xml" extension.

Fix examples:

./xmltool -fix bad.xml > good.xml
./xmltool -fix DIR_CONTAINING_BAD_XML_FILES -outdir ~/Good

These "fix" bad XML that might be dumped out of a database e.g.

<dodgy>
  <hello>Richa&rd</hello>
  <richard.lehane@gmail.com>
</dodgy>

becomes

<dodgy>
  <hello>Richa&amp;rd</hello>
  &lt;richard.lehane@gmail.com&gt;
</dodgy>

Audit examples:

./xmltool -audit good.xml
./xmltool -audit ~/Good -html > report.html // -html flag outputs report in html format

When run on the "good.xml" file generated by the -fix example above, audit returns the following information:

hello
Occurs 1 times in total, 1 times with contents, in 1 files
Example content: Richa&rd

Install with go install github.com/richardlehane/xmltool@latest

About

command line tool for cleaning up XML files


Languages

Language:Go 100.0%