import java.io.FileOutputStream;
import java.io.IOException;
import com.sun.xml.txw2.output.IndentingXMLStreamWriter;
public class XMLWriterExample {
public static void main(String[] args) {
try {
XMLWriter writer = new XMLWriter(new FileOutputStream("output.xml"));
writer.setIndentation(true);
writer.startDocument();
writer.startElement("Root");
writer.startElement("Element");
writer.addAttribute("attribute", "value");
writer.writeText("Content");
writer.endElement();
writer.endElement();
writer.endDocument();
writer.close();
System.out.println("XML document created successfully.");
} catch (IOException e) {
System.out.println("Error creating XML document: " + e.getMessage());
}
}
}