About the welformedness of the XML File, perhaps you could include the DTD of the XML File in the document,sth like
<!DOCTYPE foo SYSTEM foo.dtd>
then set your DOM Parser Factory to be validating e.g
factory=DocumentBuilderFactory.newInstance();
factory.setValidating(true);
Hope it helps
Ken
Code snippet
===========
OutputFormat outputFormat = new OutputFormat("XML","ISO-8859-1",true);
.......
outputFormat.setDoctype(null,"emp.dtd")
It adds the DOCTYPE element but doesnt create the .DTD file.
<!DOCTYPE ROOT_EL SYSTEM "emp.dtd">
Any ideas?
Rgds,
Seetesh