Android examples for XML:XML Child Element
get Child XML Element
/**// w w w.ja v a 2s . c o m * Copyright (c) 2009 Aurora Software Technology Studio. All rights reserved. */ //package com.java2s; import org.w3c.dom.Element; import org.w3c.dom.NodeList; public class Main { /** * @param parent the parent XML element * @param childName the child node name * @return the child XML element with specified node name or <code>null</code> if does not exist */ public static Element getChildElement(final Element parent, final String childName) { Element child = null; if (parent != null) { NodeList children = parent.getElementsByTagName(childName); if (children.getLength() > 0) { child = (Element) children.item(0); } } return child; } }