XML Java

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
public class MainClass{
  public static void main(String[] args) throws XMLStreamException {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true);
    XMLStreamWriter writer = outputFactory.createXMLStreamWriter(System.out);
    writer.writeStartDocument("1.0");
    writer.writeStartElement("http://www.t.com/f", "sample");
    writer.writeAttribute("attribute", "true");
    writer.writeAttribute("http://www.t.com/f", "attribute2", "false");
    writer.writeCharacters("some text");
    writer.writeCData("");
    writer.writeEndElement();
    writer.writeEndDocument();
    writer.flush();
  }
}