Here you can find the source of getFirstChildElement(Element root)
Parameter | Description |
---|---|
root | The root element to look for children in. |
public static Element getFirstChildElement(Element root)
//package com.java2s; /* (c) 2014 Open Source Geospatial Foundation - all rights reserved * (c) 2001 - 2013 OpenPlans/*w w w . j ava 2 s. c om*/ * This code is licensed under the GPL 2.0 license, available at the root * application directory. */ import org.w3c.dom.Element; import org.w3c.dom.Node; public class Main { /** * getFirstChildElement purpose. * * <p> * Used to help with XML manipulations. Returns the element which * represents the first child. * </p> * * @param root The root element to look for children in. * * @return The element if a child was found, the null otherwise. */ public static Element getFirstChildElement(Element root) { Node child = root.getFirstChild(); while (child != null) { if (child.getNodeType() == Node.ELEMENT_NODE) { return (Element) child; } child = child.getNextSibling(); } return null; } }