code: public static int getXpathIndexInt(String path) {
  
          int pos1 = path.lastIndexOf('/');
          int pos2 = path.lastIndexOf('[');
          if ((pos2 < 0) || (pos1 > pos2)) {
              return 1;
          }
  
          String idxStr = path.substring(pos2 + 1, path.lastIndexOf(']'));
          try {
              return Integer.parseInt(idxStr);
          } catch (NumberFormatException e) {
              // NOOP
          }
          return 1;
      }
docs: Returns the last Xpath index from the given path as integer.<p>
  
  Examples:<br>
  <code>title</code> returns 1<p>
  <code>title[1]</code> returns 1<p>
  <code>title/subtitle</code> returns 1<p>
  <code>title[1]/subtitle[2]</code> returns 2<p>
  
  @param path the path to extract the Xpath index from
  
  @return the last Xpath index from the given path as integer