Android examples for XML:XML Element
get Color Property from parent XML Element
//package com.java2s; import java.awt.Color; import org.w3c.dom.Element; import org.w3c.dom.NodeList; 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 Color getColorProperty(Element properties, String name) { String[] rgb = getPropertyNode(properties, name).getAttributes() .getNamedItem(COLOR_ATTR).getNodeValue().split(","); return new Color(new Integer(rgb[0]), new Integer(rgb[1]), new Integer(rgb[2])); }//from www .j av a2 s . c o m public static Element getPropertyNode(Element properties, String name) { NodeList nodeList = properties.getElementsByTagName(PROPERTY_NODE); for (int i = 0; i < nodeList.getLength(); i++) { Element element = (Element) nodeList.item(i); if (name.equals(element.getAttributes().getNamedItem(NAME_ATTR) .getNodeValue())) { return element; } } return null; } }