Java XML Element Get getElementName(Element element)

Here you can find the source of getElementName(Element element)

Description

Returns the element name of the given element.

License

Open Source License

Parameter

Parameter Description
element a parameter

Return

String

Declaration

public static String getElementName(Element element) 

Method Source Code

//package com.java2s;

import org.w3c.dom.Element;

public class Main {
    /**/*ww  w. jav  a  2  s .c o  m*/
     * Returns the element name of the given element.
     * @param element
     * @return String
     */
    public static String getElementName(Element element) {
        // When loading from disk the local name will be setup correctly, but if the local name
        // is fetched directly after calling Document.createElement() then the value will be null.
        // See the JavaDoc for more info.  To workaround this, use the complete node name.
        String elemName = element.getLocalName();
        if (elemName == null) {
            elemName = element.getNodeName();
        }
        return elemName;
    }
}

Related

  1. getElementLocalName(Element element)
  2. getElementName(Class claz)
  3. getElementName(Class clazz)
  4. getElementName(Element element)
  5. getElementName(Element element)
  6. getElementName(Field field)
  7. getElementName(Object obj)
  8. getElementNameSansNamespace(Element element)
  9. getElementNamespaces(Element element, Set namespaces)