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.
Inheritance Hierarchy
SystemObject
  MailBee.HtmlElement

Namespace: MailBee.Html
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public class Element

The Element type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleElement
Initializes a new instance of the Element class
Public methodCode exampleElement(String)
Initializes a new instance of Element object with the specified HTML markup.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetAllElements
Returns the current HTML element and all its child elements as a flat list.
Public methodGetAllElementsByName
Returns the current HTML element and all its child elements having the specified tag name as a flat list.
Public methodGetAttributeByName
Returns the HTML attribute with the specified name.
Public methodGetAttributesByName
Returns all attributes with the specified name and contained in the current HTML element.
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetInnerElementsByName
Returns the flat list containing elements with the specified tag name and contained in the current HTML element.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodCode exampleProcess
Applies the specified tag processing rules to the current element and any its child elements, calling a delegate for every tag which matches the specified rules.
Public methodCode exampleProcessToString
Applies the specified tag processing rules to the copy of the current element and any its child elements, calling a delegate for every tag which matches the specified rules, and returns the resulting OuterHtml as a string.
Public methodRemove
Removes this HTML element from InnerElements collection of its parent.
Public methodStop
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyAttributes
Gets the list of all attributes of the HTML tag.
Public propertyInnerElements
Gets the list of HTML elements directly contained in the current HTML element.
Public propertyCode exampleInnerHtml
Gets or sets the inner HTML contents of the current HTML element.
Public propertyOuterHtml
Gets or sets the text representation of the current HTML element.
Public propertyTagDefinition
Gets or sets the tag definition of the current HTML element.
Public propertyCode exampleTagName
Gets or sets the tag name of the current HTML element.
Top
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(String) 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(RuleSet, ProcessElementDelegate) or ProcessToString(RuleSet, ProcessElementDelegate) 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.

Examples
See Also