2

I am looking for a tool which can fix XML documents, particularly HTML documents. (Well I know HTML is not XML, but is very close to it - in essence, we could consider HTML/HTML5 as an XML-like document format with far lesser constraints.)

On the fix, I am thinking on such transformations:

  • making not closed tags closed (intuitively, by finding a good place for the closing tags)
  • making standalone HTML tags (like <br>, <meta>) self-closed (<br/>, <meta .../>)
  • ...and any similar, which is needed to convert a text file to a valid XML document.

The goal is the ability to process HTML5 documents by XML stylesheets.

Best option would be if it could be made working in a Linux command line.

2

Try tidy

○ →  apt search ^tidy
Sorting... Done
Full Text Search... Done
tidy/focal,now 2:5.6.0-11 amd64 [installed]
  HTML/XML syntax checker and reformatter


○ → apt-file show tidy
tidy: /etc/tidy.conf                      
tidy: /usr/bin/tidy
tidy: /usr/share/doc/tidy/changelog.Debian.gz
tidy: /usr/share/doc/tidy/copyright
tidy: /usr/share/man/man1/tidy.1.gz
NAME
       tidy - check, correct, and pretty-print HTML(5) files

DESCRIPTION
       Tidy reads HTML, XHTML, and XML files and writes cleaned-up markup. 
       For HTML variants, it detects, reports, and corrects many common
       coding errors and strives to produce visually equivalent markup 
       that is both conformant to the HTML specifications and that works in
       most browsers.

       A common use of Tidy is to convert plain HTML to XHTML.  
       For generic XML files, Tidy is limited to correcting basic well-formedness
       errors and pretty printing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.