public static void main(String args[]) throws Exception { XMLElement elt = new XMLElement("FOO"); elt.setAttribute(null, "good"); XMLWriter writer = new XMLWriter(System.out); writer.write(elt); }
/** Adds an attribute to current element of the DOM Document. */ public void addAttribute(String name, double value) { // Remove the awkard .0 at the end of each number String str = Double.toString(value); if (str.endsWith(".0")) str = str.substring(0, str.length() - 2); current.setAttribute(name, str); }
/** Adds an attribute to current element of the DOM Document. */ public void addAttribute(String name, int value) { current.setAttribute(name, Integer.toString(value)); }
/** Adds an attribute to current element of the DOM Document. */ public void addAttribute(String name, boolean value) { current.setAttribute(name, new Boolean(value).toString()); }
/** Adds an attribute to current element of the DOM Document. */ public void addAttribute(String name, String value) { if (value != null) { current.setAttribute(name, value); } }