Android XML Serializer Write simpleText(final XmlSerializer serializer, final String prefix, final String tag, final String text)

Here you can find the source of simpleText(final XmlSerializer serializer, final String prefix, final String tag, final String text)

Description

Insert an attribute-less tag with enclosed text in a XML serializer output.

License

Apache License

Parameter

Parameter Description
serializer an XML serializer
prefix an XML prefix, see XmlSerializer#startTag(String,String)
tag an XML tag
text some text to insert, or <tt>null</tt> to omit completely this tag

Exception

Parameter Description
IOException an exception

Declaration

public static void simpleText(final XmlSerializer serializer,
        final String prefix, final String tag, final String text)
        throws IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import org.xmlpull.v1.XmlSerializer;
import java.io.IOException;

public class Main {
    /**//from   ww w .j  a va2s .c  om
     * Insert an attribute-less tag with enclosed text in a XML serializer output.
     *
     * @param serializer an XML serializer
     * @param prefix an XML prefix, see {@link XmlSerializer#startTag(String, String)}
     * @param tag an XML tag
     * @param text some text to insert, or <tt>null</tt> to omit completely this tag
     * @throws IOException
     */
    public static void simpleText(final XmlSerializer serializer,
            final String prefix, final String tag, final String text)
            throws IOException {
        if (text != null) {
            serializer.startTag(prefix, tag);
            serializer.text(text);
            serializer.endTag(prefix, tag);
        }
    }
}

Related

  1. multipleTexts(final XmlSerializer serializer, final String prefix, final String... tagAndText)
  2. textTag(XmlSerializer xml, String namespace, String name, Object text)
  3. writeBitmapAttribute(XmlSerializer out, String name, Bitmap value)
  4. writeBitmapAttribute(XmlSerializer out, String name, Bitmap value)
  5. writeBooleanAttribute(XmlSerializer out, String name, boolean value)