Convert Element List to Node list - Android XML

Android examples for XML:XML Node List

Description

Convert Element List to Node list

Demo Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    /**//w  ww.  j  a  va2  s .  c  o  m
     * @param list
     * @return
     */
    public static List<Element> filterElements(NodeList list) {
        List output = new ArrayList<Element>();

        for (int i = 0; i < list.getLength(); i++) {
            if (list.item(i) instanceof Element) {
                output.add(list.item(i));
            }
        }

        return output;
    }
}

Related Tutorials