Table of Contents

Class HtmlEntity

Namespace
HtmlAgilityPack
Assembly
HtmlAgilityPack.dll

A utility class to replace special characters by entities and vice-versa. Follows HTML 4.0 specification found at http://www.w3.org/TR/html4/sgml/entities.html Follows Additional specification found at https://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references See also: https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references

public class HtmlEntity
Inheritance
HtmlEntity
Inherited Members

Properties

EntityName

A collection of entities indexed by name.

public static Dictionary<int, string> EntityName { get; }

Property Value

Dictionary<int, string>

EntityValue

A collection of entities indexed by value.

public static Dictionary<string, int> EntityValue { get; }

Property Value

Dictionary<string, int>

Methods

DeEntitize(string)

Replace known entities by characters.

public static string DeEntitize(string text)

Parameters

text string

The source text.

Returns

string

The result text.

Entitize(HtmlNode)

Clone and entitize an HtmlNode. This will affect attribute values and nodes' text. It will also entitize all child nodes.

public static HtmlNode Entitize(HtmlNode node)

Parameters

node HtmlNode

The node to entitize.

Returns

HtmlNode

An entitized cloned node.

Entitize(string)

Replace characters above 127 by entities.

public static string Entitize(string text)

Parameters

text string

The source text.

Returns

string

The result text.

Entitize(string, bool)

Replace characters above 127 by entities.

public static string Entitize(string text, bool useNames)

Parameters

text string

The source text.

useNames bool

If set to false, the function will not use known entities name. Default is true.

Returns

string

The result text.

Entitize(string, bool, bool)

Replace characters above 127 by entities.

public static string Entitize(string text, bool useNames, bool entitizeQuotAmpAndLtGt)

Parameters

text string

The source text.

useNames bool

If set to false, the function will not use known entities name. Default is true.

entitizeQuotAmpAndLtGt bool

If set to true, the [quote], [ampersand], [lower than] and [greather than] characters will be entitized.

Returns

string

The result text