Java XML Element Get getElements(Element aElement)

Here you can find the source of getElements(Element aElement)

Description

get Elements

License

Open Source License

Parameter

Parameter Description
aElement a parameter

Declaration

public static List<Element> getElements(Element aElement) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2011 www.isandlatech.com (www.isandlatech.com)
 * 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:/*from   ww  w .ja va  2 s  .co  m*/
 *    ogattaz (isandlaTech) - 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 {
    /**
     * @param aElement
     * @return
     */
    public static List<Element> getElements(Element aElement) {

        if (aElement == null) {
            return null;
        }
        List<Element> wElmts = new ArrayList<Element>();
        NodeList wList = aElement.getChildNodes();
        for (int wI = 0; wI < wList.getLength(); wI++) {
            if (wList.item(wI).getNodeType() == Node.ELEMENT_NODE) {
                wElmts.add((Element) wList.item(wI));
            }
        }
        return wElmts;
    }
}

Related

  1. getElementNS(Element root, Set nsUris, String wantedLocalName)
  2. getElementPath(Element elem)
  3. getElementPath(Element element)
  4. getElementPath(Element element)
  5. getElementPosition(Element element)
  6. getElements(Element document, String elementName, String attrName, String attrValue)
  7. getElements(Element elem, String path)
  8. getElements(Element element)
  9. getElements(Element element, String tagName)