Dom4j:Writing a document to a file import java.io.File; import java.io.FileOutputStream; import org.dom4j.Document; import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; public class Demo1 { public static void main(String[] args) throws Excep…