//sw.writeCharacters("Root text <> ]]>\n");
sw.writeEndElement();
//sw.writeEmptyElement("secondRoot"); // error!
sw.writeCharacters("\n"); // white space in epilog
sw.writeProcessingInstruction("target", "some data");
sw.writeCharacters("\n"); // white space in epilog
sw.writeEndDocument();
sw.flush();
sw.close();