code: protected static String getAttribute(Node node, String name, boolean required) {
          NamedNodeMap attributes = node.getAttributes();
          Node idNode = attributes.getNamedItem(name);
          if (idNode == null) {
              if (required) {
                  throw new IllegalArgumentException(toPath(node) + " has no " + name + " attribute");
              }
              else {
                  return "";
              }
          }
          else {
              String value = idNode.getNodeValue();
              if (value == null) {
                  return "";
              }
              return value;
          }
      }
docs: Get an Attribute from the given node and throwing an exception in the case it is required but
  not present
  
  @param node
  @param name
  @param required
  @return