Java XML Attribute Get getAttribute(String name, Element firstElement, Element secondElement)

Here you can find the source of getAttribute(String name, Element firstElement, Element secondElement)

Description

Try to get an attribute value from two elements.

License

Apache License

Parameter

Parameter Description
firstElement a parameter
secondElement a parameter

Return

attribute value

Declaration

private static String getAttribute(String name, Element firstElement,
        Element secondElement) 

Method Source Code

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

import org.w3c.dom.Element;

public class Main {
    /**/*  www.j a v  a2s  . c o  m*/
     * Try to get an attribute value from two elements.
     *
     * @param firstElement
     * @param secondElement
     * @return attribute value
     */
    private static String getAttribute(String name, Element firstElement,
            Element secondElement) {
        String val = firstElement.getAttribute(name);
        if (val.length() == 0 && secondElement != null) {
            val = secondElement.getAttribute(name);
        }
        return val;
    }
}

Related

  1. getAttribute(String attribute, Node node)
  2. getAttribute(String attribute, Node node)
  3. getAttribute(String key, NamedNodeMap map)
  4. getAttribute(String name, Element el)
  5. getAttribute(String name, Element element)
  6. getAttribute(String name, Node node)
  7. getAttributeAsBoolean(Element elem, String attribName)
  8. getAttributeAsBoolean(Element element, String attrName, boolean defValue)
  9. getAttributeAsBoolean(Element element, String attrName, boolean defValue)