Element Class
Represents a base class for all document elements.
- Inheritance:
- System.ObjectElement
- Derived
Remarks
All document content elements contain properties like ElementType, Document and Parent. These properties are defined on an Element class - a base class for all document elements.
For more information, see GemBox.Document Content Model.
Properties
Content
Gets the content of the current Element.
Property Value
The content of the current Element.
Remarks
For more information, see Get Content example.
Document
Gets the owner document.
public virtual DocumentModel Document { get; }
Public Overridable ReadOnly Property Document As DocumentModel
Property Value
The owner document.
ElementType
Gets the ElementType of this Element instance.
public abstract ElementType ElementType { get; }
Public MustOverride ReadOnly Property ElementType As ElementType
Property Value
The ElementType of this Element instance.
Parent
Gets the parent of this Element instance.
Property Value
ParentCollection
Gets the ElementCollection that contains this Element instance.
public ElementCollection ParentCollection { get; }
Public ReadOnly Property ParentCollection As ElementCollection
Property Value
The ElementCollection that contains this Element instance.
Methods
Clone(Boolean)
Clones this Element instance, and optionally clones it's descendants.
public Element Clone(bool cloneDescendants)
Public Function Clone(cloneDescendants As Boolean) As Element
Parameters
cloneDescendants
- System.Boolean
true to clone descendants; otherwise false.
Returns
Remarks
Document content element instance can exist only in a one place in the document.
If you want to insert document content element into some other part of the same document, then clone the element and insert its clone.
If you want to insert document content element into another document, then you should first import it into another document with Import<T>(T, Boolean, Boolean) method and then insert the imported element.
For more information, see cloning example.
GetChildElements(Boolean)
Gets the child elements.
public IEnumerable<Element> GetChildElements(bool recursively)
Public Function GetChildElements(recursively As Boolean) As IEnumerable(Of Element)
Parameters
recursively
- System.Boolean
true to get all descendants elements; otherwise false to get just child elements.
Returns
- System.Collections.Generic.IEnumerable<Element>
Sequence of child elements.
GetChildElements(Boolean, ElementType[])
Gets the child elements filtered by ElementType.
public IEnumerable<Element> GetChildElements(bool recursively, params ElementType[] filterElements)
Public Function GetChildElements(recursively As Boolean, ParamArray filterElements As ElementType()) As IEnumerable(Of Element)
Parameters
recursively
- System.Boolean
true to get all descendants elements; otherwise false to get just child elements.
filterElements
- ElementType[]
The ElementTypes to filter by.
Returns
- System.Collections.Generic.IEnumerable<Element>
Sequence of child elements filtered by ElementType.
GetParentElements()
Gets the parent elements.
public IEnumerable<Element> GetParentElements()
Public Function GetParentElements As IEnumerable(Of Element)
Returns
- System.Collections.Generic.IEnumerable<Element>
Sequence of parent elements.
GetParentElements(ElementType[])
Gets the parent elements.
public IEnumerable<Element> GetParentElements(params ElementType[] filterElements)
Public Function GetParentElements(ParamArray filterElements As ElementType()) As IEnumerable(Of Element)
Parameters
filterElements
- ElementType[]
The ElementTypes to filter by.
Returns
- System.Collections.Generic.IEnumerable<Element>
Sequence of parent elements.