title: Comparing length of paths
body: <p>I'm trying to keep only closest paths, I made code count occurrence of slashes and I got the result:</p>
  
  <pre><code>html/body/div/header/div/div/a/span = 7
  html/body/div/div/div/div/div/div/div/div/div/h2 = 11
  html/body/div/div/div/table/tbody/tr/td/ul/li/a = 11
  html/body/div/div/div/table/tbody/tr/td/ul/li/a/h1 = 12
  html/body/div/div/div/div/table/tbody/tr/td/a/span = 11
  html/body/div/div/div/div/table/tbody/tr/td/a/span/h1 = 12
  html/body/div/div/div/div/table/tbody/tr/td/a/a/span/h1 = 13
  </code></pre>
  
  <p>I want by the end keep only paths which are near of each others, it must return something like this:</p>
  
  <pre><code>html/body/div/div/div/div/div/div/div/div/div/h2 = 11
  html/body/div/div/div/table/tbody/tr/td/ul/li/a = 11
  html/body/div/div/div/table/tbody/tr/td/ul/li/a/h1 = 12
  html/body/div/div/div/div/table/tbody/tr/td/a/span = 11
  html/body/div/div/div/div/table/tbody/tr/td/a/span/h1 = 12
  html/body/div/div/div/div/table/tbody/tr/td/a/a/span/h1 = 13 
  </code></pre>
  
  <p>I start with this Java code: </p>
  
  <pre><code>ArrayList&lt;String&gt; list_input = new ArrayList();
          list_input.add("");
  
          list_input.add("html/body/div/header/div/div/a/span");
          list_input.add("html/body/div/div/div/div/div/div/div/div/div/h2");
          list_input.add("html/body/div/div/div/table/tbody/tr/td/ul/li/a");
          list_input.add("html/body/div/div/div/table/tbody/tr/td/ul/li/a/h1");
          list_input.add("html/body/div/div/div/div/table/tbody/tr/td/a/span");
          list_input.add("html/body/div/div/div/div/table/tbody/tr/td/a/span/h1");
          list_input.add("html/body/div/div/div/div/table/tbody/tr/td/a/a/span/h1");
  
          for (int i = 0; i &lt; list_input.size(); i++) {
              String line = (String) list_input.get(i);
  
              int count_nodes = line.length() - line.replace("/", "").length();
              System.out.println(line + " = " + count_nodes);
  
          }
  </code></pre>
  
  <p>Would someone help me to achieve this result? </p>