循环遍历xml-docs列表,保存xpath tolist

时间:2014-05-24 20:03:24

标签: xml xpath

我有这个方法:

我这样称呼方法:

var gtin = GetListGT();

希望从xpath中选择值gtin

 public List<string> GetListGT()
        {
            HtmlWeb web = new HtmlWeb();
            HtmlDocument doc = web.Load("http://www.dabas.com/mypages/search.aspx?typ=FP&sosokord=laggen");

            var xpath = "/html/body/div/div[2]/div[2]/table[9]/tbody/tr[2]/td[2]";
            var gtin = doc.DocumentNode.SelectNodes(xpath) 
            ***Think i miss something here in order to add the info from the node to the list***
            return gtin.ToList();
        }

任何人都能看到我错过的东西吗?

1 个答案:

答案 0 :(得分:0)

尝试return gtin.Select(n => n.InnerText).ToList();