나는 코드를 통해 의견을 추가하려고 최선을 다했지만 특정 부분에 달라 붙었다.누군가이 HtmlAgilityPack 코드를 설명 할 수 있습니까?
// create a new instance of the HtmlDocument Class called doc
1: HtmlDocument doc = new HtmlDocument();
// the Load method is called here to load the variable result which is html
// formatted into a string in a previous code snippet
2: doc.Load(new StringReader(result));
// a new variable called root with datatype HtmlNode is created here.
// Im not sure what doc.DocumentNode refers to?
3: HtmlNode root = doc.DocumentNode;
4:
// a list is getting constructed here. I haven't had much experience
// with constructing lists yet
5: List<string> anchorTags = new List<string>();
6:
// a foreach loop is used to loop through the html document to
// extract html with 'a' attributes I think..
7: foreach (HtmlNode link in root.SelectNodes("//a"))
8: {
// dont really know whats going on here
9: string att = link.OuterHtml;
// dont really know whats going on here too
10: anchorTags.Add(att)
11: }
이 코드 샘플을 here에서 해제했습니다. Farooq Kaiser에 대한 크레딧
나는 라이브러리를 사용한 적이 없으며 여기 어둠 속에서 찌르다가 있지만 doc.DocumentNode는 문서의 현재 노드라고 가정합니다. 문서를로드하면 문서가로드됩니다. 루트 노드. –