code: public static String getValueFromElement(Element element, String tagName) {
          NodeList elementNodeList = element.getElementsByTagName(tagName);
          if (elementNodeList == null) {
              return "";
          } else {
              Element tagElement = (Element) elementNodeList.item(0);
              if (tagElement == null) {
                  return "";
              }
  
              NodeList tagNodeList = tagElement.getChildNodes();
              if (tagNodeList == null || tagNodeList.getLength() == 0) {
                  return "";
              }
              return tagNodeList.item(0).getNodeValue();
          }
      }
docs: Gets the string value of the tag element name passed
  
  @param element
  @param tagName
  @return