Here is an example of using Java's DOM facilities to create a new XML file:
We have used XMLUnit to compare the XML we created with our sample XML. To do this, make sure the sample XML is available, i.e. that the following class is added to your CLASSPATH:
You may also want to see Using MarkupBuilder for Agile XML creation.