What libraries should I use to build an XML document from pieces of existing ones and then output it as a string? - 10.23.00

bob mcwhirter



To programatically assemble an XML document, I'd scan in each document you wish to use as sources, with either DOM, or my favorite, JDOM.

Once you have the documents in a DOM/JDOM tree, you can rather easily pull out the portions you want, and reconstruct a new document containing the desired subtrees from the source documents.

While DOM is the 'standard', I find JDOM more useful for the Java programmer for manipulating XML documents as a structure, instead of a stream of bytes.