public static Element firstChildElement(Element element,String childElementName,String attrName,String attrValue){
  if (element == null)   return null;
  Node node=element.getFirstChild();
  if (node != null) {
    do {
      if (node.getNodeType() == Node.ELEMENT_NODE && (childElementName == null || childElementName.equals(node.getLocalName() != null ? node.getLocalName() : node.getNodeName()))) {
        Element childElement=(Element)node;
        String value=childElement.getAttribute(attrName);
        if (value != null && value.equals(attrValue)) {
          return childElement;
        }
      }
    }
 while ((node=node.getNextSibling()) != null);
  }
  return null;
}

public static Element firstChildElement ( Element element , String childElementName , String attrName , String attrValue ) { if ( element == null ) return null ; Node node = element . getFirstChild ( ) ; if ( node != null ) { do { if ( node . getNodeType ( ) == Node . ELEMENT_NODE && ( childElementName == null || childElementName . equals ( node . getLocalName ( ) != null ? node . getLocalName ( ) : node . getNodeName ( ) ) ) ) { Element childElement = ( Element ) node ; String value = childElement . getAttribute ( attrName ) ; if ( value != null && value . equals ( attrValue ) ) { return childElement ; } } } while ( ( node = node . getNextSibling ( ) ) != null ) ; } return null ; }
return the first child element with the given name ; if name is null returns the first element .
