Guest antsh Posted September 11, 2008 Share Posted September 11, 2008 Hi,I have a problem with using XPath. I have a HTML table like in the bottom and I want to make a function: getTextFromTable("columnName", "rowName"). Example:getTextFromTable("Address", "Bill") -> returns "Gate 22"At the moment my problem is that I can't get XPath to return a Number that would tell me what column/row to use in getTextFromTable.Is it possible with XPath?The table: <html><head><table border="1"><tr> <td><a href="#">Name</a></td> <td><a href="#">Surname</a></td> <td><a href="#">Address</a></td></tr><tr> <td><a href="#">John</a></td> <td><a href="#">Conar</a></td> <td><a href="#">Gate 5</a></td></tr><tr> <td><a href="#">Sarah</a></td> <td><a href="#">Conar</a></td> <td><a href="#">Gate 34</a></td></tr><tr> <td><a href="#">Bill</a></td> <td><a href="#">Gates</a></td> <td><a href="#">Gate 22</a></td></tr></table></body></html> Link to comment Share on other sites More sharing options...
boen_robot Posted September 11, 2008 Share Posted September 11, 2008 You'll have so somehow associate the column name with a row position. In the example below, the "2" means the third column. If it's the first column (i.e. "Bill"), the whole "following-sibling::td[2]" will have to be removed. //table//td[//* = 'Bill']/following-sibling::td[2] (note: I haven't tested this, so it may not work... but it gives you an idea of where to start looking) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.