get Customer Xml by building XML String with StringBuffer - Android XML

Android examples for XML:XML String

Description

get Customer Xml by building XML String with StringBuffer

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        String name = "java2s.com";
        System.out.println(getCustomerXml(name));
    }//from   w w w.j  a  v  a 2  s.c o  m

    public static String getCustomerXml(String name) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("<customer>");
        buffer.append("<name>" + name + "</name>");
        buffer.append("</customer>");

        return buffer.toString();
    }

    public static String getCustomerXml(String name, String uname,
            String password) {
        StringBuffer buffer = new StringBuffer();
        buffer.append("<customer>");
        buffer.append("<name>" + name + "</name>");
        buffer.append("<uname>" + uname + "</uname>");
        buffer.append("<password>" + password + "</password>");
        buffer.append("</customer>");

        return buffer.toString();
    }
}

Related Tutorials