Android examples for XML:XML Element
Format XML Element String with String.format
//package com.java2s; public class Main { public static void main(String[] argv) throws Exception { String name = "java2s.com"; String value = "java2s.com"; System.out.println(FormatElement(name, value)); }//w ww. j a va 2s . co m public static String FormatElement(String name, String value) { return String.format("<%1$s>%2$s</%1$s>\n", name, value); } }