title: XPath How to retrieve the value of a table cell from html document
body: <p>I have a html document and somewhere inside the doc is below a table, I can get the table rows and java DOM objects.  What is not clear to me is how to extract the value of the table cell when the value is a string and also when it is a binary resource? </p>
  
  <p>I am using code like:</p>
  
  <pre><code>  XPath xpath;
     XPathExpression expr;
     NodeList nodes=null;
     // Use XPath to obtain whatever you want from the (X)HTML
     try{
  
        xpath = XPathFactory.newInstance().newXPath();
        //&lt;table class="data"&gt;
  
        NodeList list = doc.getElementsByTagName("table");
       // Node node = list.item(0); 
       //System.out.println(node.getTextContent());
      //String textContent=node.getTextContent();
  
      expr = xpath.compile("//table/tr/td");
      nodes = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
  </code></pre>
  
  <p>and loopiong like:</p>
  
  <pre><code>     for (int i = 0; i &lt; nodes.getLength(); i++) {
  
         Node ln = list.item(i);
         String lnText=ln.toString();
         NodeList rowElements=ln.getChildNodes();
         Node one=rowElements.item(0);
  
         String oneText=one.toString();
         String nodeName=one.getNodeName();
         String valOne = one.getNodeValue();
  </code></pre>
  
  <p>But I am not seeing the values in the table.</p>
  
  <pre><code> &lt;table class="data"&gt;
   &lt;tr&gt;&lt;td&gt;ImageName1&lt;/td&gt;&lt;td width="50"&gt;&lt;/td&gt;&lt;td&gt;&lt;img src="/images/036000291452" alt="036000291452" /&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;ImageName2&lt;/td&gt;&lt;td width="50"&gt;&lt;/td&gt;&lt;td&gt;&lt;img src="/images/36000291452" alt="36000291452" /&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;Description&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;Time Magazine&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;Size/Weight&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;14 Issues&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;Issuing Country&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;United States&lt;/td&gt;&lt;/tr&gt;
    &lt;/table&gt;
  </code></pre>