write xml element start tag, data and end tag into XmlStreamWriter - Java XML

Java examples for XML:XML Element Value

Description

write xml element start tag, data and end tag into XmlStreamWriter

Demo Code


//package com.java2s;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;

public class Main {
    /**/*from  www .  ja  v a2 s. c o m*/
     * write xml element start tag, data and end tag into XmlStreamWriter
     *
     * @param writer
     * @param element
     * @param value
     * @throws XMLStreamException
     */
    public static void writeSimpleDataElement(XMLStreamWriter writer,
            String element, String value) throws XMLStreamException {
        writer.writeStartElement(element);
        writer.writeCharacters(value);
        writer.writeEndElement();
    }
}

Related Tutorials