Java Utililty Methods XML Element Get

List of utility methods to do XML Element Get

Description

The list of methods to do XML Element Get are organized into topic(s).

Method

ListgetElementList(Element element)
get Element List
if (element == null) {
    return Collections.emptyList();
NodeList childNodes = element.getChildNodes();
int numChildren = childNodes.getLength();
List<Element> elementList = new ArrayList<Element>(numChildren);
for (int i = 0; i < numChildren; i++) {
    Node childNode = childNodes.item(i);
...
NodeListgetElementList(Element element, String name)
Return a list of named Elements.
return element.getElementsByTagName(name);
ListgetElementList(final Element element)
Obtains the list of child element nodes.
final List<Element> elementList = new ArrayList<Element>();
final NodeList childNodes = element.getChildNodes();
final int numChildren = childNodes.getLength();
for (int i = 0; i < numChildren; i++) {
    final Node childNode = childNodes.item(i);
    if (childNode.getNodeType() != Node.ELEMENT_NODE) {
        continue;
    elementList.add((Element) childNode);
return elementList;
StringgetElementLocalName(Element element)
get Element Local Name
String localName = null;
if (element == null) {
    throw new IllegalArgumentException("The element cannot be null");
} else {
    try {
        localName = element.getLocalName();
    } catch (NoSuchMethodError e) {
        localName = element.getTagName();
...
StringgetElementName(Class claz)
Returns the element name of the specified class.
try {
    XmlType annotation = claz.getAnnotation(XmlType.class);
    if (annotation.name() != null) {
        return annotation.name();
} catch (Exception e) {
return claz.getSimpleName();
...
StringgetElementName(Class clazz)
get Element Name
while (clazz != null) {
    XmlRootElement rootElement = clazz.getAnnotation(XmlRootElement.class);
    if (rootElement != null) {
        return rootElement.name();
    clazz = clazz.getSuperclass();
throw new RuntimeException();
...
StringgetElementName(Element element)
Returns the element name of the given element.
String elemName = element.getLocalName();
if (elemName == null) {
    elemName = element.getNodeName();
return elemName;
StringgetElementName(Element element)
Get the name of the element
return element.getNodeName();
StringgetElementName(Element element)
Returns the name of the element.
if (element.getPrefix() != null && element.getPrefix().length() > 0) {
    return element.getPrefix() + ':' + element.getLocalName();
} else {
    return element.getLocalName();
StringgetElementName(Field field)
get Element Name
XmlElement element = (XmlElement) field.getAnnotation(XmlElement.class);
return !DEFAULT_NAME.equals(element.name()) ? element.name() : field.getName();