How to write self-closing element tags using XMLStreamWriter



I am trying to write a XML element tag that has to look like this :


<case type="" player=""/>


My code is :


doc.writeStartElement("case");

doc.writeAttribute("type", type);

doc.writeAttribute("player", "");

doc.writeEndElement();


But, as I expected, a closing tag is added at the end, so it looks like this :


<case type="" player=""></case>


I am trying to write a self closing element tag, but cannot find how. Does anyone know how to do that ?


No comments:

Post a Comment