title: How to get text only from the parent node in an array
body: <p>I want to get the texts associated with the xpath "//p[@class='list-group-item']". </p>
  
  <p>Below is the HTML snippet:</p>
  
  <pre><code>&lt;div _ngcontent-c3="" class="list-group bg-trans mar-no"&gt;
    &lt;p _ngcontent-c3="" class="list-group-item" style="border-bottom: 1px dotted #ddd;"&gt;
      &lt;span _ngcontent-c3="" class="badge badge-pink" id="stat_2" style="background-color: rgb(225, 124, 167);"&gt;0&lt;/span&gt;
      In Action
    &lt;/p&gt;
    &lt;p _ngcontent-c3="" class="list-group-item" style="border-bottom: 1px dotted #ddd;"&gt;
      &lt;span _ngcontent-c3="" class="badge badge-purple" id="stat_3" style="background-color: rgb(152, 98, 145);"&gt;5&lt;/span&gt;
      Completed
    &lt;/p&gt;
    &lt;p _ngcontent-c3="" class="list-group-item" style="border-bottom: 1px dotted #ddd;"&gt;
      &lt;span _ngcontent-c3="" class="badge badge-dark" id="stat_4" style="background-color: rgb(59, 65, 70);"&gt;0&lt;/span&gt;
      Closed
    &lt;/p&gt;
    &lt;p _ngcontent-c3="" class="list-group-item" style="border-bottom: 1px dotted #ddd;"&gt;
      &lt;span _ngcontent-c3="" class="badge badge-defadivt" id="stat_8" style="background-color: rgb(227, 232, 238);"&gt;0&lt;/span&gt;
      Long Term Solution
    &lt;/p&gt;
    &lt;p _ngcontent-c3="" class="list-group-item" style="border-bottom: 1px dotted #ddd;font-weight:bold"&gt;
      &lt;span _ngcontent-c3="" class="badge badge-defadivt" id="stat_8"&gt;5&lt;/span&gt;
      Total
    &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In result I want "In action", "Completed", "Closed", Total". </p>
  
  <p>Below is the code I have written so far.</p>
  
  <pre><code>List&lt;WebElement&gt; lst= driver.findElements(By.xpath("//p[@class='list-group-item']"));
  List&lt;String&gt; strgs = new ArrayList&lt;String&gt;();
  
  for(WebElement e1 : lst){
      strgs.add(e1.getText());
  }
  System.out.println(strgs);
  </code></pre>
  
  <p>Output I got:</p>
  
  <pre><code>[
    0 In Action, 
    5 Completed,
    0 Closed, 
    0 Long Term Solution, 
    5 Total
  ]
  </code></pre>