Java XML Child Get by Namespace getChildElementsByTagNameNS(Element parent, String namespaceURI, String localName)

Here you can find the source of getChildElementsByTagNameNS(Element parent, String namespaceURI, String localName)

Description

get Child Elements By Tag Name NS

License

LGPL

Declaration

public static List<Element> getChildElementsByTagNameNS(Element parent, String namespaceURI, String localName) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

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> getChildElementsByTagNameNS(Element parent, String namespaceURI, String localName) {
        List<Element> elems = new ArrayList<Element>();
        NodeList nodes = parent.getChildNodes();
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE && node.getNamespaceURI().equals(namespaceURI)
                    && node.getLocalName().equals(localName)) {
                elems.add((Element) node);
            }//from   w w  w.  j  a  v a 2s .c  o  m
        }
        return elems;
    }
}

Related

  1. getChildElementsByTagNameNS(Element parentElement, String namespaceURI, String localName)
  2. getChildElementsByTagNameNS(Vector vector, Node node, String tagName, String namespace)
  3. getChildElementValueNS(Element parentElm, String elementNamespaceURI, String elementLocalName)