title: Xquery to extract text in html
body: <p>I am working on extracting text out of html documents and storing in database. I am using webharvest tool for extracting the content. However I kind of stuck at a point. Inside webharvest I use XQuery expression inorder to extract the data. The html document that I am parsing is as follows:</p>
  
  <pre><code>              &lt;td&gt;&lt;a name="hw"&gt;HELLOWORLD&lt;/a&gt;Hello world&lt;/td&gt;
  </code></pre>
  
  <p>I need to extract "Hello world" text from the above html script.</p>
  
  <p>I have tried extracting the text in this fashion:</p>
  
  <pre><code>     $hw :=data($item//a[@name='hw']/text())
  </code></pre>
  
  <p>However what I always get is "HELLOWORLD" instead of "Hello world".</p>
  
  <p>Is there a way to extract "Hello World". Please help.</p>
  
  <p>What if I want to  do it this way:</p>
  
  <pre><code>&lt;td&gt;
   &lt;a name="hw1"&gt;HELLOWORLD1&lt;/a&gt;Hello world1
   &lt;a name="hw2"&gt;HELLOWORLD2&lt;/a&gt;Hello world2
   &lt;a name="hw3"&gt;HELLOWORLD3&lt;/a&gt;Hello world3
  &lt;/td&gt;
  </code></pre>
  
  <p>I would like to extract the text Hello world 2 that is in betweeb hw2 and hw3. I would not want to use text()[3] but is there some way I could extract the text out between /a[@name='hw2'] and /a[@name='hw3'].</p>