This project has moved and is read-only. For the latest updates, please go here.
1
Vote

htmlDoc.DocumentNode.SelectNodes("//ul/div[@class='p-normal']")只能得到得一个

description

foreach (HtmlNode item in htmlDoc.DocumentNode.SelectNodes("//ul/div[@class='p-normal']"))
                {
                    for (int j = 1; j < 31; j++)
                    {
                        if (item.SelectNodes("ul/li[" + j.ToString() + "]") != null)
                        {
                            foreach (HtmlNode ac in item.SelectNodes("ul/li[" + j.ToString() + "]"))
                            {



                            }
                        }
                    }


                }


//
public class loveganli
    {
        public string userid;
        public string img;
        public string trace_link;
        public string trace;
        public string age;
        public string height;
        public string magic;
        public string place;

    }

file attachments

comments

zhouweiaccp wrote May 17, 2013 at 4:30 PM

// //list.Add(new loveganli
                    //           // {
                    //           //     trace = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-name']/a").Attributes["href"].Value,
                    //           //     trace_link = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-name']/a").InnerText,
                    //           //     userid = ac.Id,
                    //           //     age = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-detail']/span[1]").InnerText,
                    //           //     height = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-detail']/span[2]").InnerText,
                    //           //     place = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-detail']/span[4]").InnerText,
                    //           //     magic = ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-detail']/span[3]").InnerText,
                    //           //     img = ac.SelectSingleNode("//div[@class='p-lconr']/a/img").Attributes["src"].Value


                    //           // });

这里面永远是第一个li 子类( ac.SelectSingleNode("//div[@class='p-lconl']/p[@class='p-detail']/span[3]").)