XMLStreamWriter writer = // create XMLStreamWriter writer.writeStartElement("book"); // start element tag writer.writeAttribute("id", "123"); // write attribute writer.writeEmptyElement("title"); // write empty element tag writer.writeEndElement(); // end element tagIn this example, an XML document is being created with a book element that has an id attribute and a title element that is empty. The XMLStreamWriter's writeEmptyElement method is called to write the empty title element tag. This method is useful for cases where an element has no content but still needs to be included in the XML document. This method is part of the javax.xml.stream package library which is included in the Java SE platform.