Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Agility Pack Find ids starting with

I am a completly noob on XPath, I am doing application to fetch data from a website, and I need to find 2 things:

1- all the span tags that start with: ctl00_Main_GridView_lieutenants

2- the href of the parent tag on the span.... errr.. I will try to explain:

<a href="something.html"><span id="ctl00_Main_GridView_lieutenants_ctl03_lbl_nick">Text</span></a>

I need the Text and the link ;)

like image 658
Killercode Avatar asked Aug 30 '11 12:08

Killercode


1 Answers

//span[starts-with(@id, 'ctl00_Main_GridView_lieutenants')]

Selects all span which @id starts with ctl00_Main_GridView_lieutenants

//a[span[starts-with(@id, 'ctl00_Main_GridView_lieutenants')]]/@href

Selects all @href of a which have child span which @id starts with ctl00_Main_GridView_lieutenants

like image 180
Kirill Polishchuk Avatar answered Oct 14 '22 15:10

Kirill Polishchuk