public static List<Element> getChildElementsByTagNameNS(Element parent, String tagName,
            String nsName)
    {
        if (parent == null || tagName == null)
            return Collections.<Element> emptyList();

        NodeList nl = parent.getChildNodes();
        int size = nl.getLength();
        ArrayList<Element> childElements = new ArrayList<Element>(size);
        for (int i = 0; i < size; i++)
        {
            Node node = nl.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE)
            {
                if (tagName.equals(node.getLocalName()))
                {
                    String ns = node.getNamespaceURI();
                    if (ns != null && ns.equals(nsName))
                    {
                        childElements.add((Element) node);
                    }
                }
            }
        }

        return childElements;
    }