Hadi
Hadi

Reputation: 21

Dividing an one-line HTML file to well-formed HTML file

I have an HTML file in which all tags are in one line. I would like to separate each tag and put it on its own line. The end goal is to have a well-formed HTML file.

e.g.

<html><head><title>StackOverflow</title></head><body></body></html>

would be converted into:

<html>
    <head>
        <title>
        StackOverflow
        </title>
    </head>
    <body>
    </body>
</html>

Is there an existing Java library that handles this already?

Upvotes: 0

Views: 485

Answers (1)

loscuropresagio
loscuropresagio

Reputation: 1952

Your problem has nothing to do with well-formed HTML files. Even if html tags are on the same line, doesn't mean that the html is not well formed. What you actually neeed is just a formatter, which basically will make your html more human-readable. You could take a look at JTidy, which can optionally do also a syntax checking.

Upvotes: 2

Related Questions