Created
April 3, 2013 15:27
-
-
Save lmatt-bit/5302231 to your computer and use it in GitHub Desktop.
Html Agility Pack Usage Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using HtmlAgilityPack; | |
| //Download http://somapage | |
| WebClient wc = new WebClient(); | |
| var page = wc.DownloadString("http://somepage"); | |
| //use Html Agility Pack to load Html | |
| HtmlDocument doc = new HtmlDocument(); | |
| doc.LoadHtml(page); | |
| //Find Element by id | |
| var TargetNode = doc.GetElementbyId("SomeId"); | |
| //Find nodes by some condition | |
| var TargetNodeSubList = TargetNode.SelectNodes("//div/p[@class='content']"); | |
| //Find single node by some condition | |
| var TargetNodeSubNode = TargetNode.SelectSingleNode("//a[@title='nextpage']"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment