html agility pack - c# htmlagilitypack parse first link from div with class? -


i trying parse first link in html code below /search?id=3

<div class="brs_col">   <p>     <a href="/search?id=3">       <b>         vastu shastra       </b>     </a>   </p>   <p>     <a href="/search?id=1">       <b>         bygga       </b>       bastu     </a>   </p> </div> 

i've tried select following xpath, cant seem of them work:

//div[@class='brs_col']//p//a[@href] //div[@class='brs_col']//p[0]//a[@href] //div[@class='brs_col']//p//a[0][@href] 

any ideas?

try this:

var doc = new htmldocument(); doc.loadhtml(@"<div class=""brs_col"">                   <p><a href=""/search?id=3""><b>vastu shastra</b></a></p>                   <p><a href=""/search?id=1""><b>bygga</b>bastu</a></p>                 </div>"); var hrefvalue = doc.documentnode                    .selectsinglenode("//div[@class='brs_col']/p/a")                    .attributes["href"]                    .value; 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -