Answer the question
In order to leave comments, you need to log in
How to split data from cells from a table using Xpath?
I have the following html table:
<table class="info">
<tbody>
<tr><td class="name">Year</td><td>2011</td></tr>
<tr><td class="name">Storey</td><td>3</td></tr>
<tr><td class="name">Area</td><td>170</td></tr>
<tr><td class="name">Condition</td><td>Renovated</td></tr>
<tr><td class="name">Bathroom</td><td>2</td></tr>
</tbody>
</table>
<td>
. The first cell contains information about the data type. For example, the year of construction (Year). The second cell contains the year itself (2011). Answer the question
In order to leave comments, you need to log in
//table[@class="info"]//tr//td/text()What is the purpose of using "//" between tr and td if td is an immediate child of tr? In my opinion, it is better to specify the most specific xpath expression. Also, please clarify in which environment (programming language) you are using these expressions.
//table[@class="info"]/tbody/tr/td[1]/text()
, you will get the values //table[@class="info"]/tbody/tr/td[2]/text()
will give //table[@class="info"]/tbody/tr
and then, iterating over them, get the values of expressions td[1]/text()
and td[2]/text()
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question