开发者

C# Xpath Tables

I have the xml code that contains to a table with 2 rows.

<table>
       <thead>
              <tr>
                  <td class="num">test</td>
                  <td class="num">test2</td>
              </tr>
       </thead>
</table>

I am using xpath to开发者_如何学JAVA grap the data from the row. how do i retrieve only the first row data from the table and not all the data.

The xpath code i am using now is:

/table/thead/tr/th[@class='num']

And my current output is:

test
test2

What do I have to add in the xpath code so I can select the first row only?


Your result is the expected output, the XPath expression asks for all nodes which match, and the two you get are therefore correct.

If you want only the first one, you can do this:

/table/thead/tr/th[@class='num'][1]

Otherwise post your expectation...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜