HtmlAgilityPack not looping through collection
问题 I have a webpage with a collection of div's with the class "messages". I am trying to loop through them and put them into a CSV file, however I cant get the collection to loop properly. Here is the code: string fpath = @"C:\Texts\messages.html"; HtmlDocument page = new HtmlWeb().Load(fpath); var msgs = page.DocumentNode.SelectNodes("//div[@class='message']"); List<string> msgList = new List<string>(); foreach (var msg in msgs) { msgList.Add(msg.InnerHtml); } The msg stays the same through