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

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -