fork download
  1. import javax.xml.stream.XMLOutputFactory;
  2. import javax.xml.stream.XMLStreamWriter;
  3.  
  4. class xml {
  5.  
  6. public static void main(String[] args) throws Exception{
  7. XMLStreamWriter xsw = XMLOutputFactory.newInstance()
  8. .createXMLStreamWriter(System.out);
  9. xsw.writeStartDocument();
  10. xsw.writeStartElement("root");
  11. xsw.writeStartElement("child");
  12. xsw.writeAttribute("c", "3");
  13. xsw.writeAttribute("b", "2");
  14. xsw.writeAttribute("a", "1");
  15. xsw.writeEndElement();
  16. xsw.writeEndDocument();
  17. xsw.close();
  18. }
  19. }
Success #stdin #stdout 0.09s 380672KB
stdin
Standard input is empty
stdout
<?xml version="1.0" ?><root><child c="3" b="2" a="1"></child></root>