Labels

slider

Recent

Navigation

HAP: Learn to Install HTML agility pack and Load an HTML Document

Install html agility pack, Load a HTML Document using html agility pack, Load DOM using HTML Agility Pack, install HTML agility pack, html agility pack tutorial c#

Introduction

The HTML Agility pack is one amazing library that gives a C# developer all the abilities to play with DOM loading and parsing at ease. In order to enter into that comfort zone, it is required for you to first install HTML agility pack since it is minimum that is required to acquaint with its capabilities.

HTML Agility Pack Installation

This section walks you through the procedure about how to install HTML agility pack nuget package with simple and lucid words. You could also take help by watching this video where steps are explained in detail.
Learn to Install HTML agility pack and Load an HTML Document

Free Video Library: Learn HTML Agility Pack Step by Step

  1. First, you can install nuget package from the link.
  2. Under the section, Package Manager copy the install code. For example, if there is content such as PM> Install-Package HtmlAgilityPack -Version 1.5.1, then you shall copy the text that follows after PM>.
  3. After copying the code, now go to your Visual Studio Application and click on Tools menu in the menu bar.
  4. From the menu drop down, go to library manager → Package Manager Console.
  5. In the lower half of the Application, now you will see the Package Manager Console opened and the cursor blinking.
  6. You must paste the code that you copied from the site using the help of step:2 by using the combination of hotkeys Ctrl and V.
  7. After pasting the code hit enter and the application will take care of the installation.


Using the HAP

After successful installation, as an enthusiastic, you would be overwhelmed to learn about how to Load an HTML Document using HTML agility pack or Load DOM using HTML Agility Pack. This section exactly takes care of that. All you will have to do is to follow the below-mentioned steps.

Using the HAP

After successful installation, as an enthusiastic, you would be overwhelmed to learn about how to Load an HTML Document using HTML agility pack or Load DOM using HTML Agility Pack. This section exactly takes care of that. All you will have to do is to follow the below-mentioned steps.
  1. First, it is required to add a DLL reference. To do that, you need to go into the Visual Studio Application and press on the Solution Explorer which is located in the sidebar.
  2. On the Reference text, that you find there, simply right click on it and you need to click on Add Reference, which you will find in the context menu.
  3. From the Reference Manager window, click on the browser button and point the location in your computer where the HAP dll is present and select it.
  4. Press Ok. Now come back to the code area of your Visual Studio application and insert the following code, below the list of using statements.
  5. In the main function, write down the below-given code.
  6. HtmlWeb web = new HtmlWeb();
    HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); 
    doc = web.load(“https://technologycrowds.com”);
    
  7. Save the code and click on Start Button. Hover over the line doc=web.load(“https://technologycrowds.com”); and from the drop down, click on DocumentNode and then press the InnerHtml.
  8. On the space beside the InnerHtml, click on the search icon and you will be seeing a new window that opens up. The newly loaded window will have all the DOM contents which are nothing but the HTML content of the web page.

Relevant HTML Agility Pack Topics

Share

Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

0 comments: