import javax.xml.namespace.QName;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
public class Utils {
/**
* Recursive method to find a given attribute value
*/
public static String recursiveGetAttributeValue(Element element, String attributeName) {
String answer = null;
try {
answer = element.getAttribute(attributeName);
} catch (Exception e) {
}
if (answer == null || answer.length() == 0) {
Node parentNode = element.getParentNode();
if (parentNode instanceof Element) {
return recursiveGetAttributeValue((Element) parentNode, attributeName);
}
}
return answer;
}
}
|