Here you can find the source of getChildElement(String name, Element elem)
Parameter | Description |
---|---|
name | Name of the requested child element. |
elem | Parent element. |
public static Element getChildElement(String name, Element elem)
//package com.java2s; /* /*from w ww . j a va 2s. c o m*/ * XMLUtils.java * * Copyright (C) August Mayer, 2001-2004. All rights reserved. * Please consult the Boone LICENSE file for additional rights granted to you. * * Created on 09. Dezember 2002, 16:31 */ import org.w3c.dom.*; public class Main { /** * Get a child element with a specific name. * * @param name Name of the requested child element. * @param elem Parent element. * * @return The first child element with the given name, or null if none found. */ public static Element getChildElement(String name, Element elem) { NodeList l = elem.getChildNodes(); for (int i = 0; i < l.getLength(); i++) { Node n = l.item(i); if (n instanceof Element && n.getNodeName().equals(name)) return (Element) n; } return null; } }