I am trying to create a Java Application that retrieves information from a webpage. This is part of the code I am trying to access the value in the 1st td tag in the 2nd tr tag:
<TABLE CLASS="datadisplaytable" width = "100%">
<TR>
<TD CLASS="dddead"> </TD>
<TH CLASS="ddheader" scope="col" ><SPAN class="fieldlabeltext">Capacity</SPAN></TH>
<TH CLASS="ddheader" scope="col" ><SPAN class="fieldlabeltext">Actual</SPAN></TH>
<TH CLASS="ddheader" scope="col" ><SPAN class="fieldlabeltext">Remaining</SPAN></TH>
</TR>
<TR>
<TH CLASS="ddlabel" scope="row" ><SPAN class="fieldlabeltext">Seats</SPAN></TH>
**<TD CLASS="dddefault">46</TD>**
<TD CLASS="dddefault">46</TD>
<TD CLASS="dddefault">0</TD>
</TR>
This is what i have right now but this only returns the class of the td tag and not the value inside it:
List<?> table = page.getByXPath("//table[@class='datadisplaytable'][1]//tr[2]/td");
How would I go about getting the value of the td tag and not its properties?
edit: The code above returns this:
HtmlTableDataCell[<td class="dddefault">]
Assuming that the document is as shown in the question (
TABLEis the top element),Use:
This selects any text-node child of the first
TDchild of the secondTRchild of the top elementTABLE.In case the table is buried in the XML document, but can be uniquely identified by its
CLASSattribute, use:This selects any text-node child of the first
TDchild of the secondTRchild of any (we know thre is only one such) elementTABLEin the XML document, such that the string value of itsCLASSattribute is the string'datadisplaytable'.Finally, if even worse, there could be many
TABLEelements whoseCLASSattribute’s value is'datadisplaytable', and we want to select in the first such table, use: