title: Selecting a portion of text in html Using Java
body: <p>I have looked through multiple forms before asking this question.Basically, what i need is to select part of the text in a HTML file. the html is constructed something like this </p>
  
  <pre><code>&lt;div class = "pane big"&gt;
  &lt;code&gt;
  &lt;pre&gt;
  SomeText
  &lt;a id="par1" href="#par1"&gt;¶&lt;/a&gt;
  MoreText
  .
  .
  .
  &lt;a id="par2" href="#par2"&gt;¶&lt;/a&gt;
  MoreText
  &lt;/pre&gt;
  &lt;/code&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So what i need to do, is to extract the text under the href tag par1 by itself and then get the text under par2 href tag separately. i tried to use Jsoup but all i could do is to select the whole text withing the div. Also tried XPath but the expression that I'm evaluating is not accepted. not sure maybe because it's not an XML file to begin with. </p>
  
  <p>and example of XPath expressions that I used is . </p>
  
  <pre><code>/html/body/div/div[2]/code[2]/pre/text()[3]
  </code></pre>
  
  <p>and CSS </p>
  
  <pre><code>body &gt; div &gt; div.pane.big &gt; code:nth-child(7) &gt; pre
  </code></pre>