2011-08-30 41 views
7

我在XPath中完全地小白,我做的應用程序從一個網站獲取數據,我需要找到兩件事情:HTML敏捷性包查找IDS開始

1-所有span標籤與開始:ctl00_Main_GridView_lieutenants

2 - 上跨度父標籤的href .... errr ..我會盡量解釋:

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

我需要的文字和鏈接;)

+0

你也可以考慮使用jQuery(代替) –

回答

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

選擇所有跨度其中@id開始與ctl00_Main_GridView_lieutenants

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

選擇的a所有@href具有孩子span@id開始與ctl00_Main_GridView_lieutenants