Class HtmlNode
- Namespace
- SimpleSign.HtmlToPdf.Parsing
- Assembly
- SimpleSign.HtmlToPdf.dll
Lightweight HTML DOM node. Represents either an element (div, p, table...) or a text node. This is not a full DOM -- just enough structure for layout and rendering.
public sealed class HtmlNode
- Inheritance
-
HtmlNode
- Inherited Members
Properties
Attributes
HTML attributes (lowercase keys). Empty for text nodes.
public Dictionary<string, string> Attributes { get; init; }
Property Value
Children
Child nodes.
public List<HtmlNode> Children { get; }
Property Value
ComputedStyle
Computed style after cascade resolution. Populated by StyleResolver.
public ComputedStyle? ComputedStyle { get; set; }
Property Value
InlineStyle
Inline style attribute parsed into individual properties. Populated by StyleResolver.
public Dictionary<string, string> InlineStyle { get; set; }
Property Value
IsBlock
Gets a value indicating whether this is a block-level element.
public bool IsBlock { get; }
Property Value
IsTableElement
Gets a value indicating whether this is a table-related element.
public bool IsTableElement { get; }
Property Value
IsVoid
Gets a value indicating whether this is a void/self-closing element.
public bool IsVoid { get; }
Property Value
NodeType
Gets the type of this node.
public HtmlNodeType NodeType { get; init; }
Property Value
Parent
Parent node. Null for the root node.
public HtmlNode? Parent { get; }
Property Value
Tag
Tag name in lowercase (e.g., "div", "p", "table"). Null for text nodes.
public string? Tag { get; init; }
Property Value
Text
Text content. Only set for text nodes.
public string? Text { get; init; }
Property Value
Methods
AppendChild(HtmlNode)
Adds a child node and sets its parent.
public void AppendChild(HtmlNode child)
Parameters
childHtmlNodeThe child node to add.
CreateElement(string, HtmlNode?)
Creates a new element node with the given tag.
public static HtmlNode CreateElement(string tag, HtmlNode? parent = null)
Parameters
Returns
- HtmlNode
A new element node.
CreateText(string, HtmlNode?)
Creates a new text node with the given content.
public static HtmlNode CreateText(string text, HtmlNode? parent = null)
Parameters
Returns
- HtmlNode
A new text node.
Descendants(string)
Gets all descendant elements matching a tag name.
public IEnumerable<HtmlNode> Descendants(string tag)
Parameters
tagstringThe tag name to search for (lowercase).
Returns
- IEnumerable<HtmlNode>
An enumerable of matching descendant nodes.
GetAttribute(string)
Gets attribute value or null.
public string? GetAttribute(string name)
Parameters
namestringThe attribute name (case-insensitive).
Returns
- string
The attribute value, or null if not found.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.