Question

I have tried several combinations without success. The full xpath to that data is .//*[@id='detail_row_seek_37878']/td The problem is the number portion '37878' changes for each node and thus I can't use a foreach to loop through the nodes. Is there some way to use a wildcard and reduce the xpath to .//*[@id='detail wildcard, in an effort to bypass the absolute value portion? I am using html agility pack on this.

 HtmlNode ddate = node.SelectSingleNode(".//*[@id='detail_row_seek_37878']/td");

Accepted Answer

Extract the portion that doesn't change:

//*[starts-with(@id, 'detail_row_seek')]/td

Related Techniques and Functions

To match elements whose id attribute contains the string _row_ at the 7th character:

//*[substring(@id, 7, 5)='_row_']/td 

To match elements whose id attribute contains the text detail_ at any position:

//*[contains(@id, 'detail_')]/td 

To match elements whose id attribute ends with the text detail_row_seek:

//*['detail_row_seek' = substring(@id, 
        string-length(@id) - string-length('detail_row_seek') + 1)]/td 



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why