Java XML Element Get getElementList(Element dataRoot, String name)

Here you can find the source of getElementList(Element dataRoot, String name)

Description

get Element List

License

Open Source License

Declaration

public static List<Element> getElementList(Element dataRoot, String name) 

Method Source Code

//package com.java2s;
/**/*  w ww  .  j  a  va2  s  . co  m*/
 * Cilea Commons Framework
 * 
 * Copyright (c) 2008, CILEA and third-party contributors as
 *  indicated by the @author tags or express copyright attribution
 *  statements applied by the authors.  All third-party contributions are
 *  distributed under license by CILEA.
 * 
 *  This copyrighted material is made available to anyone wishing to use, modify,
 *  copy, or redistribute it subject to the terms and conditions of the GNU
 *  Lesser General Public License v3 or any later version, as published 
 *  by the Free Software Foundation, Inc. <http://fsf.org/>.
 * 
 *  This program 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 Lesser General Public License
 *  for more details.
 * 
 *   You should have received a copy of the GNU Lesser General Public License
 *   along with this distribution; if not, write to:
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor
 *   Boston, MA  02110-1301  USA
 */

import java.util.ArrayList;

import java.util.List;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class Main {
    public static List<Element> getElementList(Element dataRoot, String name) {
        NodeList list = dataRoot.getElementsByTagName(name);
        List<Element> listElements = new ArrayList<Element>();
        for (int i = 0; i < list.getLength(); i++) {
            listElements.add((Element) list.item(i));
        }
        return listElements;
    }
}

Related

  1. getElementIndex(Element element)
  2. getElementLanguage(Element elemNode, String defaultLangCode)
  3. getElementLanguage(Element elemNode, String defaultLangCode)
  4. getElementList(Document doc, String expression)
  5. getElementList(Element dataRoot, String name)
  6. getElementList(Element element)
  7. getElementList(Element element, String name)
  8. getElementList(final Element element)
  9. getElementLocalName(Element element)