Try our conversational search powered by Generative AI!

Class ElementFragment

Represents a HTML element.

Inheritance
System.Object
ElementFragment
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.HtmlParsing
Assembly: EPiServer.Framework.dll
Version: 11.20.7
Syntax
public class ElementFragment : TokenFragmentBase<ElementToken>

Constructors

ElementFragment()

Initializes a new instance of the ElementFragment class.

Declaration
public ElementFragment()

Properties

Attributes

Gets the attributes for this HTML element.

Declaration
public AttributeCollection Attributes { get; }
Property Value
Type Description
AttributeCollection

The attributes.

CallbackOnEndElement

Gets or sets the callback to perform when a matching End element is found.

Declaration
public Action CallbackOnEndElement { get; set; }
Property Value
Type Description
System.Action

The System.Action callback to perform.

Remarks

By setting this property to an Action when a ElementFragment is returned by the enumerator, the Action will be invoked when the matching EndElementFragment is returned.

Important! This setting is mirrored by the CallbackOnEndElement property on HtmlStreamReader, but it is recommended to use the property on ElementFragment since it is much more consistent with the data flow.

HasAttributes

Gets a value indicating whether this instance has attributes.

Declaration
public bool HasAttributes { get; }
Property Value
Type Description
System.Boolean

true if this instance has attributes; otherwise, false.

Methods

Parse(IHtmlParserContext)

Parses a HTML element.

Declaration
public override void Parse(IHtmlParserContext context)
Parameters
Type Name Description
IHtmlParserContext context

The context.

Overrides
Remarks

The initial '<' has already been consumed and parsing continues until the entire element has been properly parsed.

ToWriter(TextWriter)

Outputs this HTML element to the writer.

Declaration
public override void ToWriter(TextWriter writer)
Parameters
Type Name Description
System.IO.TextWriter writer

The writer.

Overrides

Extension Methods