以下是我的 html 片段,有 N 个带有类名的 DIVquality
现在我想提取<a href>
每个具有质量的类名的 div。
Eastin Easy Citizen 艾哈迈达巴德
<div class="quality wrap">
<a href="/Hotel_Review-g297608-d4464287-Reviews-Eastin_Easy_Citizen_Ahmedabad-Ahmedabad_Gujarat.html" id="property_4464287"class="property_title" onclick=" ta.setEvtCookie('Reviews', 'HotelName', 297608, 0, this.href); ta.util.cookie.setPIDCookie(15176);">
Eastin Easy Citizen Ahmedabad</a> </div>
<div class="quality wrap">
<a href="/Hotel_Review-g297608-d4464287-Reviews-Eastin_Easy_Citizen_Ahmedabad-Ahmedabad_Gujarat.html" id="property_4464287"class="property_title" onclick=" ta.setEvtCookie('Reviews', 'HotelName', 297608, 0, this.href); ta.util.cookie.setPIDCookie(15176);">
Eastin Easy Citizen Ahmedabad</a> </div>
<div class="quality wrap">
<a href="/Hotel_Review-g297608-d4464287-Reviews-Eastin_Easy_Citizen_Ahmedabad-Ahmedabad_Gujarat.html" id="property_4464287"class="property_title" onclick=" ta.setEvtCookie('Reviews', 'HotelName', 297608, 0, this.href); ta.util.cookie.setPIDCookie(15176);">
Eastin Easy Citizen Ahmedabad</a> </div>
我试过以下
var nS = page.DocumentNode.SelectNodes("//div[@class='quality']//a");
foreach (HtmlNode linkNode in nS)
{
//do something
}
但我得到NullPointerException
任何人都可以帮助我