Android examples for XML:XML Element
add Color Property to XML Element
//package com.java2s; import java.awt.Color; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static final String PROPERTY_NODE = "property"; public static final String NAME_ATTR = "name"; public static final String COLOR_ATTR = "colorvalue"; public static void addColorProperty(Document document, Element parent, String name, Color value) { addPropertyNode(document, parent, name).setAttribute( COLOR_ATTR,// www. ja v a 2 s . com value.getRed() + "," + value.getGreen() + "," + value.getBlue()); } private static Element addPropertyNode(Document document, Element parent, String name) { Element element = document.createElement(PROPERTY_NODE); parent.appendChild(element); element.setAttribute(NAME_ATTR, name); return element; } }