c# - How to loop on rows HtmlAgilityPack -
i have been scrapping long time started learning htmlagilitypack.
i not sure how loop through items brings same item each time.
code:
htmlnodecollection nodesmatchingxpath = mainnode.selectnodes("//tr[@class='ad_listitem']"); if (nodesmatchingxpath.count > 0) { foreach (htmlnode hn in nodesmatchingxpath) { htmlnode title = hn.selectsinglenode("//a[@class='name_psb_link hover_text_decoration']"); if (title != null) { // same title each time meaning xpath } } } i see doea items count 200 , not sure if rite way loop through them or path brings same info each time, maybe searching on whole document instead of single node.
an xpath expression starting / (like "//a[@class='name_psb_link hover_text_decoration']") starts root, not current node!
start . (like ".//a[@class='name_psb_link hover_text_decoration']") start current node.
Comments
Post a Comment