Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:23:27+00:00 2026-05-30T22:23:27+00:00

I am trying to create a Java Application that retrieves information from a webpage.

  • 0

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">&nbsp;</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">]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:23:28+00:00Added an answer on May 30, 2026 at 10:23 pm

    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:

    Assuming that the document is as shown in the question (TABLE is the top element),

    Use:

    /TABLE/TR[2]/TD[1]/text()
    

    This selects any text-node child of the first TD child of the second TR child of the top element TABLE.

    In case the table is buried in the XML document, but can be uniquely identified by its CLASS attribute, use:

    //TABLE[@CLASS='datadisplaytable']/TR[2]/TD[1]/text()
    

    This selects any text-node child of the first TD child of the second TR child of any (we know thre is only one such) element TABLE in the XML document, such that the string value of its CLASS attribute is the string 'datadisplaytable'.

    Finally, if even worse, there could be many TABLE elements whose CLASS attribute’s value is 'datadisplaytable', and we want to select in the first such table, use:

    (//TABLE[@CLASS='datadisplaytable'])[1]/TR[2]/TD[1]/text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a browser based application that can access Java Objects
I am trying to create a Java Application Client project that sends a JMS
I'm trying to create a java desktop application that holds desktop icons. The app
I'm trying to create an application in Java that will print an image based
I'm trying to create an application event (java) that would raise as soon as
I have a Java JDBC application that uses multiple threads to retrieve information from
I'm trying to create a simple To-Do list Java application connected to MS Access
I am trying to create a Debian package for a Java application. In my
I am trying to create my first GUI application using (Java + Eclipse +
I m trying to create a desktop application using swing in java, which allows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.