Java XML Element Get by Name getElements(Element parentElement, String nodeName)

Here you can find the source of getElements(Element parentElement, String nodeName)

Description

get Elements

License

Open Source License

Declaration

public static Element[] getElements(Element parentElement, String nodeName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

public class Main {
    public static Element[] getElements(Element parentElement, String nodeName) {
        NodeList list = parentElement.getElementsByTagName(nodeName);
        if (list == null) {
            return new Element[0];
        }/* w  w w  . j av a 2  s. c  o m*/
        Element[] eles = new Element[list.getLength()];
        for (int i = 0; i < list.getLength(); i++) {
            Node node = list.item(i);
            eles[i] = (Element) node;
        }
        return eles;
    }
}

Related

  1. getElements(Element parent, String localName)
  2. getElements(Element parent, String localname, String namespaceURI)
  3. getElements(Element parent, String tagName)
  4. getElements(Element parent, String tagName)
  5. getElements(Element parent, String tagName)
  6. getElements(final Element parent, final String name)
  7. getElementsByName(Element parent, String name)
  8. getElementsByTagName(Document doc, String tagName)
  9. getElementsByTagName(Element parent, String name, boolean localOnly)