title: How to get the value of text node inside <div> element using XPATH and Jtidy
body: <p>I have been banging my head over for two days now.
  I have a XHTML web-page from which i want to scrap some data 
  I am using JTidy to DOMParse and then XPathFactory to find nodes using XPath</p>
  
  <p>The Xhtml snippet is something like this</p>
  
  <pre><code>    &lt;div style="line-height: 22px;" id="dvTitle" class="titlebtmbrdr01"&gt;BAJAJ AUTO LTD.&lt;/div&gt;
  </code></pre>
  
  <p>Now i want that BAJAJ AUTO LTD.</p>
  
  <p>The code that i am using is :</p>
  
  <pre><code>    import java.io.IOException;
      import java.net.MalformedURLException;
      import java.net.URL;
      import java.util.Vector;
  
      import javax.xml.xpath.XPath;
      import javax.xml.xpath.XPathConstants;
      import javax.xml.xpath.XPathExpression;
      import javax.xml.xpath.XPathExpressionException;
      import javax.xml.xpath.XPathFactory;
  
       import org.w3c.dom.Document;
      import org.w3c.dom.Node;
      import org.w3c.dom.NodeList;
  
  
     public class BSEQuotesExtractor implements valueExtractor {
  
  @Override
  public Vector&lt;String&gt; getName(Document d) throws XPathExpressionException {
      // TODO Auto-generated method stub
      XPathFactory factory = XPathFactory.newInstance();
      XPath xpath = factory.newXPath();
      XPathExpression expr = xpath.compile("//div[@id='dvTitle']/text()");
      Object result = expr.evaluate(d, XPathConstants.NODESET);
      NodeList nodes = (NodeList)result;
      for(int i=0;i&lt;nodes.getLength();i++)
      {
          System.out.println(nodes.item(i).getNodeValue());
      }
  
      return null;
  }
  
  public static void main(String[] args) throws MalformedURLException, IOException, XPathExpressionException{
      BSEQuotesExtractor q = new BSEQuotesExtractor();
      DOMParser parser = new DOMParser(new URL("http://www.bseindia.com/bseplus/StockReach/StockQuote/Equity/BAJAJ%20AUTO%20LTD/BAJAJAUT/532977/Scrips").openStream());
      Document d = parser.getDocument();
      q.getName(d);
  
  }
  
      }
  </code></pre>
  
  <p>But i gett a null output and not BAJAJ AUTO LTD.
  Please rescue me</p>