MailBee.NET Objects 4.0

Element Class

Represents an HTML element or a piece of text in the HTML document and provides properties and methods for examining or altering the contents of this element.

For a list of all members of this type, see Element Members.

System.Object
   MailBee.Html.Element

public class Element

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Remarks

Objects of this class are building blocks of DOM (document object model) of the HTML document. MailBee represents the HTML document as a tree of Element objects which can be nested within each other accordingly the HTML markup of the document. The document itself is also represented as Element object.

Each Element object has InnerElements collection of HTML elements nested in the parent one. Alternatively, you can get the list of all elements located inside the parent element, regardless of their nesting level (not important if they are nested directly in the parent element or into any of its child elements). You can use GetAllElements, GetInnerElementsByName and other methods for this.

You can also access various parts of the contents of the HTML element as a string using InnerHtml, OuterHtml, TagDefinition and TagName properties. For instance, you can set TagDefinition to a certain tag definition string and then use Attributes collection to examine the attibutes of this tag.

Use Process or ProcessToString methods for advanced processing of HTML documents. These methods allow the developer to apply a set of content-processing rules to the HTML document. These rules can be both user-defined and predefined (such as GetSafeHtmlRules which defines the rules for making HTML document contents safe and free from any potentially dangerous items such as scripts).

To get the list of links or images in the document represented by Element object, create Processor object and set Dom property to the given Element object reference, and examine AHRefs and Images property values. You can also use Processor class to read/write HTML markup from/into a stream.

Example

The example is available in AddTagReplacementRule topic.

Requirements

Namespace: MailBee.Html

Assembly: MailBee.NET (in MailBee.NET.dll)

See Also

Element Members | MailBee.Html Namespace