C# 상용 컨트롤
Html Agility Pack.
스티커
2013. 5. 9. 10:01
HTML 파싱을 보다 쉽게 할수있게 해주는 무료프레임워크
예제
BODY 태그의 내용만 가져오기
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument(); htmlDoc.LoadHtml(q); //<html><body>kojaedoo</body></html> HtmlAgilityPack.HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body"); if (bodyNode != null) { // Do something with bodyNode var bodyContent = bodyNode.InnerHtml; }
다른예제
HtmlDocument doc = new HtmlDocument(); doc.Load("file.htm"); foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href"]) { HtmlAttribute att = link["href"]; att.Value = FixLink(att); } doc.Save("file.htm");
다운로드