SimpleHTMLParser 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleHTMLParser --version 1.0.0                
NuGet\Install-Package SimpleHTMLParser -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleHTMLParser" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleHTMLParser --version 1.0.0                
#r "nuget: SimpleHTMLParser, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleHTMLParser as a Cake Addin
#addin nuget:?package=SimpleHTMLParser&version=1.0.0

// Install SimpleHTMLParser as a Cake Tool
#tool nuget:?package=SimpleHTMLParser&version=1.0.0                

SimpleHTMLParser

A simple and full-feature HTML Parser in C#

What is SimpleHTMLParser?

SimpleHTMLParser is a simple to use, efficient, and full-featured HTML Document Parser. You can parse an HTML text and retrieve any element(s) in it.

Where can I get it?

First, install NuGet. Then, install SimpleHTMLParser from the package manager console:

PM> Install-Package SimpleHTMLParser

Or from the .NET CLI as:

dotnet add package SimpleHTMLParser

var htmlText =
            @"<!DOCTYPE html>
<html lang=""en"">
<head>
    <meta charset=""UTF-8"">
    <meta name=""viewport"" content=""width=device-width, initial-scale=1.0"">
    <title>Document</title>
</head>
<body>

    <p id=""paragraph1"">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odit veritatis, assumenda quibusdam et deserunt architecto nulla eligendi quod recusandae vitae doloremque dicta quam? Asperiores, aut? Autem doloribus voluptatum itaque maiores?</p>
    <p id=""paragraph2"">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odit veritatis, assumenda quibusdam et deseru?</p>
    <p id=""paragraph3"">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odit veritatis, assumenda quibusdam et deserunt aaque maiores?</p>
    <p id=""paragraph4"">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Odit veritatis, assumenda quibusdam et deserunt architecto nulla eligendi quod recusandae vitae doloremque dicta quam? Asperiores, aut? Autem doloribus voluptatum itaque maiores?</p>
    <p>My name is Faith</p>
    <h2 class=""Header2"">Welcome to HTMLParser C# by propenster</h2>
    <p>
        This is another paragraph... 
        Loaded 'C:\MinGW\bin\libgcc_s_dw2-1.dll'. Symbols loaded.
        Loaded 'C:\MinGW\bin\libstdc++-6.dll'. Symbols loaded.

    </p>

    <div id=""myDiv"">
       <p>Paragraph under div</p>
        <p>Another paragraph under div </p>
        <span class=""mySpan"">This is a span under this DIV</span>
    </div>

</body>
</html>";

        var htmlParser = new HTMLParser();
        var htmlDocument = htmlParser.Parse(htmlText);

        //get a P Tag with a particular Attribute...
        IHtmlElement paragraph1 = htmlDocument.FindElement(By.Id("paragraph1"));

        Console.WriteLine("Paragraph1 Text >>> {0}", paragraph1?.Text ?? string.Empty);

        IHtmlElement headerElement = htmlDocument.FindElement(By.ClassName("Header2"));
        Console.WriteLine("Header2 Text >>> {0}", headerElement?.Text);

        //get div...
        IHtmlElement myDiv = htmlDocument.FindElement(By.Id("myDiv"));
        // get other elements under this DIV
        var paragraphsUnderMyDiv = myDiv.FindElements(By.ElementTag("p"));
        var spanUnderDivWithClassMySpan = myDiv.FindElements(By.ClassName("mySpan"));
        Console.WriteLine("This is the text from our Span under the DIV >>> {0}", spanUnderDivWithClassMySpan?.Text);
        Console.WriteLine("There are {0} paragraph tags under DIV myDiv", paragraphsUnderMyDiv.Count());
        




Check the examples folder for more examples.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 200 8/22/2023
1.0.0 129 8/22/2023