Class HtmlToken
- Namespace
- AngleSharp.Html.Parser.Tokens
- Assembly
- AngleSharp.dll
The abstract base class of top-level HTML tokens.
public class HtmlToken
- Inheritance
-
HtmlToken
- Derived
- Inherited Members
- Extension Methods
Constructors
HtmlToken(HtmlTokenType, TextPosition, string?)
Creates a new HTML token.
public HtmlToken(HtmlTokenType type, TextPosition position, string? name = null)
Parameters
type
HtmlTokenTypeThe exact type of the token.
position
TextPositionThe token's text position.
name
stringThe optional name of the token, if any.
Properties
Data
Gets the data of the comment or character token.
public string Data { get; }
Property Value
HasContent
Gets if the character data contains actually a non-space character.
public bool HasContent { get; }
Property Value
- bool
True if the character data contains space character.
IsEmpty
Gets if the character data is empty (null or length equal to zero).
public bool IsEmpty { get; }
Property Value
- bool
True if the character data is actually NULL or empty.
IsHtmlCompatible
Gets if the token can be used with IsHtmlTIP properties.
public bool IsHtmlCompatible { get; }
Property Value
IsMathCompatible
Gets if the token can be used with IsMathMLTIP properties.
public bool IsMathCompatible { get; }
Property Value
IsProcessingInstruction
Indicates that this comment token is a processing instruction.
public bool IsProcessingInstruction { get; }
Property Value
IsSvg
Gets if the given token is a SVG root start tag.
public bool IsSvg { get; }
Property Value
Name
Gets or sets the name of a tag token.
public string Name { get; set; }
Property Value
Position
Gets the position of the token.
public TextPosition Position { get; }
Property Value
Type
Gets the type of the token.
public HtmlTokenType Type { get; }
Property Value
Methods
AsTag()
Converts the current token to a tag token.
public HtmlTagToken AsTag()
Returns
- HtmlTagToken
The tag token instance.
IsStartTag(string)
Finds out if the current token is a start tag token with the given name.
public bool IsStartTag(string name)
Parameters
name
stringThe name of the tag.
Returns
- bool
True if the token is indeed a start tag token with the given name, otherwise false.
RemoveNewLine()
Removes the new line in the beginning, if any.
public void RemoveNewLine()
TrimStart()
Removes all ignorable characters from the beginning.
public string TrimStart()
Returns
- string
The trimmed characters.