Java Utililty Methods XML NodeList to Element List

List of utility methods to do XML NodeList to Element List

Description

The list of methods to do XML NodeList to Element List are organized into topic(s).

Method

ListtoElementList(NodeList list)
to Element List
ArrayList<Element> nodes = new ArrayList<Element>();
for (int i = 0; i < list.getLength(); i++) {
    Node node = list.item(i);
    if (node instanceof Element)
        nodes.add((Element) node);
return nodes;
ListtoElementList(NodeList nds)
to Element List
List<Element> list = new ArrayList<Element>();
for (int i = 0; i < nds.getLength(); i++) {
    Node child = nds.item(i);
    if (child.getNodeType() == Node.ELEMENT_NODE) {
        list.add((Element) child);
return list;
...
ListtoElementList(NodeList nodeList)
to Element List
List<Element> list = new ArrayList<Element>(nodeList != null ? nodeList.getLength() : 0);
if (nodeList == null)
    return list;
int n = nodeList.getLength();
for (int i = 0; i < n; i++) {
    Node item = nodeList.item(i);
    if (item instanceof Element)
        list.add((Element) item);
...
ListtoElementList(NodeList nodeList)
Gets all the elements out of a NodeList .
List<Element> elements = new ArrayList<Element>();
for (int i = 0; i < nodeList.getLength(); i++) {
    Node node = nodeList.item(i);
    if (node instanceof Element) {
        elements.add((Element) node);
return elements;
...
Element[]toElements(NodeList nl)
to Elements
if (nl.getLength() == 0) {
    return EMPTY_ELEMENTS;
List<Element> al = new ArrayList<Element>();
for (int i = 0; i < nl.getLength(); i++) {
    Node n = nl.item(i);
    if (n instanceof Element) {
        al.add((Element) n);
...
ListtoElements(NodeList nodes)
format XML into human readable form
List<Element> list = new ArrayList<Element>();
for (int i = 0; i < nodes.getLength(); i++)
    if (nodes.item(i) instanceof Element)
        list.add((Element) nodes.item(i));
return list;
ListtoElements(NodeList nodes, String filter)
To elements.
List<Element> list = new ArrayList<Element>();
for (int i = 0; i < nodes.getLength(); i++)
    if (nodes.item(i) instanceof Element) {
        Element e = (Element) nodes.item(i);
        if (filter == null || e.getTagName().equals(filter)) {
            list.add(e);
return list;