Here you can find the source of writeSimpleElement(XmlSerializer serializer, String namespace, String elementName, String elementText)
public static void writeSimpleElement(XmlSerializer serializer, String namespace, String elementName, String elementText) throws IOException, XmlPullParserException
//package com.java2s; import java.io.IOException; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlSerializer; public class Main { public static final String XSI_NS = "http://www.w3.org/2001/XMLSchema-instance"; /**/*from w w w. j av a 2 s . c o m*/ * Writes a simple element such as <username>johndoe</username>. The namespace * and elementText are allowed to be null. If elementText is null, an xsi:nil="true" * will be added as an attribute. */ public static void writeSimpleElement(XmlSerializer serializer, String namespace, String elementName, String elementText) throws IOException, XmlPullParserException { if (elementName == null) { throw new XmlPullParserException( "name for element can not be null"); } serializer.startTag(namespace, elementName); if (elementText == null) { serializer.attribute(XSI_NS, "nil", "true"); } else { serializer.text(elementText); } serializer.endTag(namespace, elementName); } }