Create xml dynamically

Hi Folks, I want to, within a batch process, create a simple peice of xml and data. Within the process I know what my tags are to be. I will have data as well. And so I simply want to construct this xml (with the tags and data) and then pass this xml as a string to another method.

There is no need for dtd's here or validation. Just simple basic ... a few tags ... a little data ...

So I can just construct this using a stringBuffer ... or do I use an api / parser ... ?

[493 byte] By [OlsonJa] at [2007-11-26 19:49:58]
# 1
it'll always be better to use an api (on is natively present in java since 1.5). Any error in your xml will be directly detected.nothing prevents you to use a string buffer aswell.
alban.maillerea at 2007-7-9 22:38:56 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Cool. Good thoughts. I can go look at the javadoc for jdk1.5 ... in lieu of that, as I am using 1.4, what api, pkg, class would be most appropriate for such a simple scenario? It seems like most of what I see in dom is geared more towards reading and parsing existing xml.
OlsonJa at 2007-7-9 22:38:56 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
This chapter here: http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.htmlprovides an example of that.
DrClapa at 2007-7-9 22:38:56 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...