I have an html table with an ID of thetable
. It has (according to FireBug), an unnamed TBODY tag, and an unnamed TR tag. The three TD tags inside that I want to access are unnamed. Is there any CSS selector that I can use to reference these unnamed tr tags?
I've tried:
table#thetable:nth-child(1)
But this does not select for those tags.
I'm using jsoup.org to pull this data into strings. I'd like to take the text of each TD in the table (of which I know the name) and put all that into an array.
Something like this:
// Pseudocode for all the TDs into an array
Elements strings = doc.select("table#thetable: children");
If you're simply looking to get all your td
elements, this should be enough:
Elements elems = doc.select("table#thetable td");
Then iterate elems
, retrieve the text from your td
s and put them in your array.
Also, you should probably use an array list instead of an array if you don't know or can't control how many cells your table will have:
Elements elems = doc.select("table#thetable td");
List<String> strings = new ArrayList<String>();
for (Element e : elems) {
strings.add(e.text());
}
You just want to access all of the cells?
#thetable td
Or do you just want to access the first row?
#thetable tr:first-of-type td
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With