try { XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter( new FileOutputStream( "E:\\playeronline.xml" ) ); writer.writeStartDocument(); writer.writeStartElement("players"); while(rs.next()) { writer.writeStartElement("player"); String guid = rs.getString("guid"); writer.writeStartElement("guid"); writer. writer.writeEndElement(); writer.writeEndElement(); } writer.writeEndElement(); writer.writeEndDocument(); writer.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (XMLStreamException e) { e.printStackTrace(); }