Here you can find the source of getElementByName(Element eParent, String elementName)
Parameter | Description |
---|---|
eParent | a parameter |
elementName | a parameter |
public static Element getElementByName(Element eParent, String elementName)
//package com.java2s; /*/* ww w . jav a 2 s. c om*/ * Copyright (c) 2004-2016 YAMJ Members * https://github.com/orgs/YAMJ/people * * This file is part of the Yet Another Movie Jukebox (YAMJ) project. * * YAMJ is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * * YAMJ is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with YAMJ. If not, see <http://www.gnu.org/licenses/>. * * Web: https://github.com/YAMJ/yamj-v2 * */ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class Main { /** * Get an element from a parent element node * * @param eParent * @param elementName * @return */ public static Element getElementByName(Element eParent, String elementName) { NodeList nlParent = eParent.getElementsByTagName(elementName); for (int looper = 0; looper < nlParent.getLength(); looper++) { if (nlParent.item(looper).getNodeType() == Node.ELEMENT_NODE) { return (Element) nlParent.item(looper); } } return null; } }