Java XML Element Get getElementByQualifiedName(Element n, String namespace, String elementName)

Here you can find the source of getElementByQualifiedName(Element n, String namespace, String elementName)

Description

Gets the first child Element with a given name

License

Apache License

Parameter

Parameter Description
n the node get the children from
namespace the namespace of the child element
elementName the name of the child elements

Return

the first child Element with a given name

Declaration

public static Element getElementByQualifiedName(Element n, String namespace, String elementName) 

Method Source Code

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

import org.w3c.dom.Element;

import org.w3c.dom.NodeList;

public class Main {
    /**/* ww  w .  jav  a2 s . c  o  m*/
     * Gets the first child Element with a given name
     *
     * @param n the node get the children from
     * @param namespace the namespace of the child element
     * @param elementName the name of the child elements
     * @return the first child Element with a given name
     */
    public static Element getElementByQualifiedName(Element n, String namespace, String elementName) {
        NodeList subNodes = n.getElementsByTagNameNS(namespace, elementName);
        int sz = subNodes.getLength();
        if (sz > 0) {
            return (Element) subNodes.item(0);
        }
        return null;
    }
}

Related

  1. getElementByFilter(Document doc, NodeFilter filter)
  2. getElementByID(Element el, String id)
  3. getElementByID(Element el, String id)
  4. getElementById(Element element, String id)
  5. getElementByName(Element ele, String name)
  6. getElementByTagName(Element current, String name)
  7. getElementByTagName(Element el, String tag)
  8. getElementByTagName(Element el, String tag)
  9. getElementByTagName(Element elem, String name, String emptyValue)