public String getValueStr(String s, String pattern) {
    String r = "";

    if (s.length() > 0 && pattern.length() > 0) {
      Pattern p =
          Pattern.compile(pattern, Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE);
      Matcher m = p.matcher(s);
      if (m.find()) {
        r = m.group(1);
      }
    } else {
      r = s;
    }

    return r;
  }
  public String getDocumentValueStr(String xpath, String pattern) {
    String s = "";

    try {
      Dom4jXPath p = new Dom4jXPath(xpath);
      p.addNamespace("h", NamespaceStr);
      s = p.stringValueOf(doc);
    } catch (Exception e) {
      System.out.println(e.getMessage());
    }

    if (s.length() > 0 && pattern.length() > 0) {
      Pattern p =
          Pattern.compile(pattern, Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE);
      Matcher m = p.matcher(s);
      if (m.find()) {
        s = m.group(1);
      }
    }

    return s.replaceAll("^[ \\s]+|\\s{2,}+|[ \\s]+$", "");
  }