I want to provide a simple XHTML representation of each of the resources in a REST web service.
At the moment i'm using a StringBuilder to generate these which is both tedious and error prone. I don't see these changing after I publish the service but the process of coding each is a bit painful.
Is there a XHTML document writer api? Should I just use an XML writer? Which one? Should I just roll my own basic HTML document class - doctype is the same each time, i just need to set the title, metatags and body content, most of which (but not all content) is already in HTML for the GETs.
Or should I just use StringBuilder and stop whining? ;)
Thanks.
You could use something like jdom or dom4j. Either one provides a simple interface for building your document and then serializing it as an XML string. It's less brittle than using a StringBuilder.
UPDATE: Corrected dom4j link.