Java XML Child Get getChildElements(Element parent)

Here you can find the source of getChildElements(Element parent)

Description

get Child Elements

License

Open Source License

Declaration

public static List<Element> getChildElements(Element parent) 

Method Source Code

//package com.java2s;
/*--------------------------------------------------------------------------
 * Copyright (c) 2004, 2006 OpenMethods, LLC
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*  ww w .ja va2  s  .  c o m*/
 *    Trip Gilman (OpenMethods), Lonnie G. Pryor (OpenMethods),
 *    Vincent Pruitt (OpenMethods)
 *    
 *    T.D. Barnes (OpenMethods) - initial API and implementation
 -------------------------------------------------------------------------*/

import java.util.ArrayList;
import java.util.List;

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

public class Main {
    public static List<Element> getChildElements(Element parent) {
        List<Element> ret = new ArrayList<Element>();
        NodeList childList = parent.getChildNodes();
        for (int i = 0; i < childList.getLength(); i++) {
            if (childList.item(i).getNodeType() != Node.ELEMENT_NODE)
                continue;
            Element child = (Element) childList.item(i);
            ret.add(child);
        }
        return ret;
    }
}

Related

  1. getChildElements(Element parent)
  2. getChildElements(Element parent)
  3. getChildElements(Element parent)
  4. getChildElements(Element parent)
  5. getChildElements(Element parent)
  6. getChildElements(Element parentElement)
  7. getChildElements(Element parentElement)
  8. getChildElements(Element parentElement, String childElementTagName)
  9. getChildElements(Element parentNode)