1

I am autogenerating HTML-Strings in Java. Unfortunately in the output everything appears in a long row. It's too much effort to put \n or \t before the Output-String due to sometimes I'm containing several objects in each other (Like Divs and Tables).

Are there some frameworks available which support HTML-Autoformat in Java? Thanks

Qohelet
  • 1,459
  • 4
  • 24
  • 41
  • Oh the irony in *too much effort*... – crush Feb 05 '14 at 17:40
  • Imagine there are several tables within a table which might contain a DIV-Element which contains stuff as well. This stuff itself is complex enough, I'm not keen on thinking about how much Tabs I need in front of every row... – Qohelet Feb 05 '14 at 17:45
  • The irony in *too much effort* was that you seemingly didn't even bother searching before asking a question that has been answered before. Of course, I don't know for a fact that you didn't search. There is a reasonable chance that you did search, and didn't find the answer suggested below. That's why I made the comment in jest, and meant no offense. – crush Feb 05 '14 at 17:48
  • As said to Daniel down there I was focused too much on how to format HTML, I haven't even thought of XML... – Qohelet Feb 05 '14 at 17:55
  • Well, HTML is basically a form of XML, though some would argue that only applies to XHTML. – crush Feb 05 '14 at 17:56

1 Answers1

3

Check this answer for pretty printing of XML (it should also work for HTML): How to pretty print XML from Java?

Community
  • 1
  • 1
Daniel
  • 471
  • 3
  • 10
  • Thank you! Obviously I haven't seen the wood for the trees. Of course a XML-Formatter does exactly that - I was focused too much on the HTML... – Qohelet Feb 05 '14 at 17:53