I want to select div nodes with different class with xpath. what should I do? I wrote this code, But it returns error.
HtmlWeb w = new HtmlWeb();
string SearchResults = "http://www.ask.com/web?q=" + query.querytxt;
var hd = w.Load(SearchResults);
var titles = hd.DocumentNode.SelectNodes("//div[contains(@class='web-result ur tsrc')] && //div[contains(@class='web-result ur tsrc_Wiki-SA '] && //div[contains(@class='web-result ur tsrc_tube youtube-result ']");
I need these divs
//div[contains(@class='web-result ur tsrc')]
//div[contains(@class='web-result ur tsrc_Wiki-SA ')]
//div[contains(@class='web-result ur tsrc_tube youtube-result ']
this is the error:
Function 'contains' in '//div[contains(@class='web-result ur tsrc')] && //div[contains(@class='web-result ur tsrc_Wiki-SA '] && //div[contains(@class='web-result ur tsrc_tube youtube-result ']' has an invalid number of arguments.
In xpath
contains()
function works with ,
to compare value instead of =
. So try as below with correct xpath
:-
//div[contains(@class, 'web-result ur tsrc')]
//div[contains(@class, 'web-result ur tsrc_Wiki-SA ')]
//div[contains(@class, 'web-result ur tsrc_tube youtube-result ')]
Hope it helps...:)