c# - Html Agility Pack get contents from table -


i need location, address, , phone number "http://anytimefitness.com/find-gym/list/al" far have this...

    htmldocument htmldoc = new htmldocument();      htmldoc.optionfixnestedtags = true;     htmldoc.loadhtml(stateurls[0].tostring());      var blanknode =          htmldoc.documentnode.selectnodes("/div[@class='segmentwhite']/table[@style='width: 100%;']//tr[@class='']");      var graynode =          htmldoc.documentnode.selectnodes("/div[@class='segmentwhite']/table[@style='width: 100%;']//tr[@class='gray_bk']"); 

i have looked around stackoverflow while none of present post regarding htmlagilitypack has helped. have have been using http://www.w3schools.com/xpath/xpath_syntax.asp

since <div> you're after not direct child of root node, need use // instead of /. can combine xpath blanknode , graynode using or operator, example :

var htmlweb = new htmlweb(); htmldocument htmldoc = htmlweb.load("http://anytimefitness.com/find-gym/list/al"); htmldoc.optionfixnestedtags = true;  var allnode =         htmldoc.documentnode.selectnodes("//div[@class='segmentwhite']/table//tr[@class='' or @class='gray_bk']"); foreach (htmlnode node in allnode) {     var location = node.selectsinglenode("./td[2]").innertext;     var address = node.selectsinglenode("./td[3]").innertext;     var phone = node.selectsinglenode("./td[4]").innertext;      //do above informations } 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -