code: public static String simplifyXpath(String path) {
  
          StringBuffer result = new StringBuffer(path);
          if (result.charAt(0) == '/') {
              result.deleteCharAt(0);
          }
          int pos = result.length() - 1;
          if (result.charAt(pos) == '/') {
              result.deleteCharAt(pos);
          }
          return result.toString();
      }
docs: Simplifies an Xpath by removing a leading and a trailing slash from the given path.<p>
  
  Examples:<br>
  <code>title/</code> becomes <code>title</code><br>
  <code>/title[1]/</code> becomes <code>title[1]</code><br>
  <code>/title/subtitle/</code> becomes <code>title/subtitle</code><br>
  <code>/title/subtitle[1]/</code> becomes <code>title/subtitle[1]</code><p>
  
  @param path the path to process
  @return the input with a leading and a trailing slash removed