Thursday, 28 July 2011

Write Start Document

  

import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;

public class MainClass {

  public static void main(String[] argsthrows Exception {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = outputFactory.createXMLStreamWriter(System.out);
    writer.writeStartDocument("1.0");
    writer.writeStartElement("person");
    writer.writeStartElement("name");
    writer.writeStartElement("fname");
    writer.writeCharacters("AAA");

    writer.writeEndDocument();
    writer.flush();
  }

}

   
  

No comments:

Post a Comment