iText 7 7.1.8 API
iText.StyledXmlParser.Jsoup.Nodes.Element Class Reference

A HTML element consists of a tag name, attributes, and child nodes (including text nodes and other elements). More...

Inheritance diagram for iText.StyledXmlParser.Jsoup.Nodes.Element:
iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Document iText.StyledXmlParser.Jsoup.Nodes.FormElement

Public Member Functions

  Element (iText.StyledXmlParser.Jsoup.Parser.Tag tag, String baseUri, Attributes attributes)
  Create a new, standalone Element. More...
 
  Element (iText.StyledXmlParser.Jsoup.Parser.Tag tag, String baseUri)
  Create a new Element from a tag and a base URI. More...
 
override String  NodeName ()
  Get the node name of this node. More...
 
virtual String  TagName ()
  Get the name of the tag for this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  TagName (String tagName)
  Change the tag of this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Parser.Tag  Tag ()
  Get the Tag for this element. More...
 
virtual bool  IsBlock ()
  Test if this element is a block-level element. More...
 
virtual String  Id ()
  Get the id attribute of this element. More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  Attr (String attributeKey, String attributeValue)
  Set an attribute value on this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Attr (String attributeKey, bool attributeValue)
  Set a boolean attribute value on this element. More...
 
virtual IDictionary< String, String >  Dataset ()
  Get this element's HTML5 custom data attributes. More...
 
sealed override iText.StyledXmlParser.Jsoup.Nodes.Node  Parent ()
  Gets this node's parent node. More...
 
virtual Elements  Parents ()
  Get this element's parent and ancestors, up to the document root. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Child (int index)
  Get a child element of this element, by its 0-based index number. More...
 
virtual Elements  Children ()
  Get this element's child elements. More...
 
virtual IList< TextNode TextNodes ()
  Get this element's child text nodes. More...
 
virtual IList< DataNode DataNodes ()
  Get this element's child data nodes. More...
 
virtual Elements  Select (String cssQuery)
  Find elements that match the iText.StyledXmlParser.Jsoup.Select.Selector CSS query, with this element as the starting context. Matched elements may include this element, or any of its children. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  AppendChild (iText.StyledXmlParser.Jsoup.Nodes.Node child)
  Add a node child node to this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  PrependChild (iText.StyledXmlParser.Jsoup.Nodes.Node child)
  Add a node to the start of this element's children. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  InsertChild (int index, iText.StyledXmlParser.Jsoup.Nodes.Node child)
  Inserts the given child node into this element at the specified index. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  InsertChildren< _T0 > (int index, ICollection< _T0 > children)
  Inserts the given child nodes into this element at the specified index. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  AppendElement (String tagName)
  Create a new element by tag name, and add it as the last child. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  PrependElement (String tagName)
  Create a new element by tag name, and add it as the first child. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  AppendText (String text)
  Create and append a new TextNode to this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  PrependText (String text)
  Create and prepend a new TextNode to this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Append (String html)
  Add inner HTML to this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Prepend (String html)
  Add inner HTML into this element. More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  Before (String html)
  Insert the specified HTML into the DOM before this element (as a preceding sibling). More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  Before (iText.StyledXmlParser.Jsoup.Nodes.Node node)
  Insert the specified node into the DOM before this node (as a preceding sibling). More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  After (String html)
  Insert the specified HTML into the DOM after this element (as a following sibling). More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  After (iText.StyledXmlParser.Jsoup.Nodes.Node node)
  Insert the specified node into the DOM after this node (as a following sibling). More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Empty ()
  Remove all of the element's child nodes. More...
 
override iText.StyledXmlParser.Jsoup.Nodes.Node  Wrap (String html)
  Wrap the supplied HTML around this element. More...
 
virtual String  CssSelector ()
  Get a CSS selector that will uniquely select this element. More...
 
virtual Elements  SiblingElements ()
  Get sibling elements. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  NextElementSibling ()
  Gets the next sibling element of this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  PreviousElementSibling ()
  Gets the previous element sibling of this element. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  FirstElementSibling ()
  Gets the first element sibling of this element. More...
 
virtual int  ElementSiblingIndex ()
  Get the list index of this element in its element sibling list. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  LastElementSibling ()
  Gets the last element sibling of this element More...
 
virtual Elements  GetElementsByTag (String tagName)
  Finds elements, including and recursively under this element, with the specified tag name. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  GetElementById (String id)
  Find an element by ID, including or under this element. More...
 
virtual Elements  GetElementsByClass (String className)
  Find elements that have this class, including or under this element. More...
 
virtual Elements  GetElementsByAttribute (String key)
  Find elements that have a named attribute set. More...
 
virtual Elements  GetElementsByAttributeStarting (String keyPrefix)
  Find elements that have an attribute name starting with the supplied prefix. More...
 
virtual Elements  GetElementsByAttributeValue (String key, String value)
  Find elements that have an attribute with the specific value. More...
 
virtual Elements  GetElementsByAttributeValueNot (String key, String value)
  Find elements that either do not have this attribute, or have it with a different value. More...
 
virtual Elements  GetElementsByAttributeValueStarting (String key, String valuePrefix)
  Find elements that have attributes that start with the value prefix. More...
 
virtual Elements  GetElementsByAttributeValueEnding (String key, String valueSuffix)
  Find elements that have attributes that end with the value suffix. More...
 
virtual Elements  GetElementsByAttributeValueContaining (String key, String match)
  Find elements that have attributes whose value contains the match string. More...
 
virtual Elements  GetElementsByAttributeValueMatching (String key, Regex pattern)
  Find elements that have attributes whose values match the supplied regular expression. More...
 
virtual Elements  GetElementsByAttributeValueMatching (String key, String regex)
  Find elements that have attributes whose values match the supplied regular expression. More...
 
virtual Elements  GetElementsByIndexLessThan (int index)
  Find elements whose sibling index is less than the supplied index. More...
 
virtual Elements  GetElementsByIndexGreaterThan (int index)
  Find elements whose sibling index is greater than the supplied index. More...
 
virtual Elements  GetElementsByIndexEquals (int index)
  Find elements whose sibling index is equal to the supplied index. More...
 
virtual Elements  GetElementsContainingText (String searchText)
  Find elements that contain the specified string. More...
 
virtual Elements  GetElementsContainingOwnText (String searchText)
  Find elements that directly contain the specified string. More...
 
virtual Elements  GetElementsMatchingText (Regex pattern)
  Find elements whose text matches the supplied regular expression. More...
 
virtual Elements  GetElementsMatchingText (String regex)
  Find elements whose text matches the supplied regular expression. More...
 
virtual Elements  GetElementsMatchingOwnText (Regex pattern)
  Find elements whose own text matches the supplied regular expression. More...
 
virtual Elements  GetElementsMatchingOwnText (String regex)
  Find elements whose text matches the supplied regular expression. More...
 
virtual Elements  GetAllElements ()
  Find all elements under this element (including self, and children of children). More...
 
virtual String  Text ()
  Gets the combined text of this element and all its children. More...
 
virtual String  OwnText ()
  Gets the text owned by this element only; does not get the combined text of all children. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Text (String text)
  Set the text of this element. More...
 
virtual bool  HasText ()
  Test if this element has any text content (that is not just whitespace). More...
 
virtual String  Data ()
  Get the combined data of this element. More...
 
virtual String  ClassName ()
  Gets the literal value of this element's "class" attribute, which may include multiple class names, space separated. More...
 
virtual ICollection< String >  ClassNames ()
  Get all of the element's class names. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  ClassNames (ICollection< String > classNames)
  Set the element's class attribute to the supplied class names. More...
 
virtual bool  HasClass (String className)
  Tests if this element has a class. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  AddClass (String className)
  Add a class name to this element's class attribute. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  RemoveClass (String className)
  Remove a class name from this element's class attribute. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  ToggleClass (String className)
  Toggle a class name on this element's class attribute: if present, remove it; otherwise add it. More...
 
virtual String  Val ()
  Get the value of a form element (input, textarea, etc). More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Val (String value)
  Set the value of a form element (input, textarea, etc). More...
 
virtual String  Html ()
  Retrieves the element's inner HTML. More...
 
override StringBuilder  Html (StringBuilder appendable)
  Write this node and its children to the given System.Text.StringBuilder . More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Element  Html (String html)
  Set this element's inner HTML. More...
 
override String  ToString ()
 
override Object  Clone ()
  Create a stand-alone, deep copy of this node, and all of its children. More...
 
- Public Member Functions inherited from iText.StyledXmlParser.Jsoup.Nodes.Node
virtual String  Attr (String attributeKey)
  Get an attribute's value by its key. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Attributes  Attributes ()
  Get all of the element's attributes. More...
 
virtual bool  HasAttr (String attributeKey)
  Test if this element has an attribute. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  RemoveAttr (String attributeKey)
  Remove an attribute from this element. More...
 
virtual String  BaseUri ()
  Get the base URI of this node. More...
 
virtual void  SetBaseUri (String baseUri)
  Update the base URI of this node and all of its descendants. More...
 
virtual String  AbsUrl (String attributeKey)
  Get an absolute URL from a URL attribute that may be relative (i.e. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  ChildNode (int index)
  Get a child node by its 0-based index. More...
 
virtual IList< iText.StyledXmlParser.Jsoup.Nodes.Node ChildNodes ()
  Get this node's children. More...
 
virtual IList< iText.StyledXmlParser.Jsoup.Nodes.Node ChildNodesCopy ()
  Returns a deep copy of this node's children. More...
 
int  ChildNodeSize ()
  Get the number of child nodes that this node holds. More...
 
iText.StyledXmlParser.Jsoup.Nodes.Node  ParentNode ()
  Gets this node's parent node. More...
 
virtual Document  OwnerDocument ()
  Gets the Document associated with this Node. More...
 
virtual void  Remove ()
  Remove (delete) this node from the DOM tree. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  Unwrap ()
  Removes this node from the DOM, and moves its children up into the node's parent. More...
 
virtual void  ReplaceWith (iText.StyledXmlParser.Jsoup.Nodes.Node @in)
  Replace this node in the DOM with the supplied node. More...
 
virtual IList< iText.StyledXmlParser.Jsoup.Nodes.Node SiblingNodes ()
  Retrieves this node's sibling nodes. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  NextSibling ()
  Get this node's next sibling. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  PreviousSibling ()
  Get this node's previous sibling. More...
 
virtual int  SiblingIndex ()
  Get the list index of this node in its node sibling list. More...
 
virtual iText.StyledXmlParser.Jsoup.Nodes.Node  Traverse (NodeVisitor nodeVisitor)
  Perform a depth-first traversal through this node and its descendants. More...
 
virtual String  OuterHtml ()
  Get the outer HTML of this node. More...
 
override String  ToString ()
 
override bool  Equals (Object o)
  Check if this node is the same instance of another (object identity test). More...
 
virtual bool  HasSameValue (Object o)
  Check if this node is has the same content as another node. More...
 

Detailed Description

A HTML element consists of a tag name, attributes, and child nodes (including text nodes and other elements).

A HTML element consists of a tag name, attributes, and child nodes (including text nodes and other elements). From an Element, you can extract data, traverse the node graph, and manipulate the HTML.

Jonathan Hedley, jonat.nosp@m.han@.nosp@m.hedle.nosp@m.y.ne.nosp@m.t

Constructor & Destructor Documentation

◆ Element() [1/2]

iText.StyledXmlParser.Jsoup.Nodes.Element.Element ( iText.StyledXmlParser.Jsoup.Parser.Tag  tag,
String  baseUri,
Attributes  attributes 
)
inline

Create a new, standalone Element.

Create a new, standalone Element. (Standalone in that is has no parent.)

Parameters
tag tag of this element
baseUri the base URI
attributes initial attributes
See also
AppendChild(Node), AppendElement(System.String)

◆ Element() [2/2]

iText.StyledXmlParser.Jsoup.Nodes.Element.Element ( iText.StyledXmlParser.Jsoup.Parser.Tag  tag,
String  baseUri 
)
inline

Create a new Element from a tag and a base URI.

Parameters
tag element tag
baseUri the base URI of this element. It is acceptable for the base URI to be an empty string, but not null.
See also
iText.StyledXmlParser.Jsoup.Parser.Tag.ValueOf(System.String)

Member Function Documentation

◆ AddClass()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.AddClass ( String  className )
inlinevirtual

Add a class name to this element's class attribute.

Parameters
className class name to add
Returns
this element

◆ After() [1/2]

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.After ( iText.StyledXmlParser.Jsoup.Nodes.Node  node )
inlinevirtual

Insert the specified node into the DOM after this node (as a following sibling).

Parameters
node to add after this element
Returns
this element, for chaining
See also
Before(Node)

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ After() [2/2]

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.After ( String  html )
inlinevirtual

Insert the specified HTML into the DOM after this element (as a following sibling).

Parameters
html HTML to add after this element
Returns
this element, for chaining
See also
Before(System.String)

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Append()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Append ( String  html )
inlinevirtual

Add inner HTML to this element.

Add inner HTML to this element. The supplied HTML will be parsed, and each node appended to the end of the children.

Parameters
html HTML to add inside this element, after the existing HTML
Returns
this element
See also
Html(System.String)

◆ AppendChild()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.AppendChild ( iText.StyledXmlParser.Jsoup.Nodes.Node  child )
inlinevirtual

Add a node child node to this element.

Parameters
child node to add.
Returns
this element, so that you can add more child nodes or elements.

◆ AppendElement()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.AppendElement ( String  tagName )
inlinevirtual

Create a new element by tag name, and add it as the last child.

Parameters
tagName the name of the tag (e.g. div ).
Returns
the new element, to allow you to add content to it, e.g.: parent.appendElement("h1").attr("id", "header").text("Welcome");

◆ AppendText()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.AppendText ( String  text )
inlinevirtual

Create and append a new TextNode to this element.

Parameters
text the unencoded text to add
Returns
this element

◆ Attr() [1/2]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Attr ( String  attributeKey,
bool  attributeValue 
)
inlinevirtual

Set a boolean attribute value on this element.

Set a boolean attribute value on this element. Setting to

true

sets the attribute value to "" and marks the attribute as boolean so no value is written out. Setting to

false

removes the attribute with the same key if it exists.

Parameters
attributeKey the attribute key
attributeValue the attribute value
Returns
this element

◆ Attr() [2/2]

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.Attr ( String  attributeKey,
String  attributeValue 
)
inlinevirtual

Set an attribute value on this element.

Set an attribute value on this element. If this element already has an attribute with the key, its value is updated; otherwise, a new attribute is added.

Returns
this element

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Before() [1/2]

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.Before ( iText.StyledXmlParser.Jsoup.Nodes.Node  node )
inlinevirtual

Insert the specified node into the DOM before this node (as a preceding sibling).

Parameters
node to add before this element
Returns
this Element, for chaining
See also
After(Node)

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Before() [2/2]

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.Before ( String  html )
inlinevirtual

Insert the specified HTML into the DOM before this element (as a preceding sibling).

Parameters
html HTML to add before this element
Returns
this element, for chaining
See also
After(System.String)

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Child()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Child ( int  index )
inlinevirtual

Get a child element of this element, by its 0-based index number.

Get a child element of this element, by its 0-based index number.

Note that an element can have both mixed Nodes and Elements as children. This method inspects a filtered list of children that are elements, and the index is based on that filtered list.

Parameters
index the index number of the element to retrieve
Returns
the child element, if it exists, otherwise throws an IndexOutOfBoundsException
See also
Node.ChildNode(int)

◆ Children()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.Children ( )
inlinevirtual

Get this element's child elements.

Get this element's child elements.

This is effectively a filter on Node.ChildNodes() to get Element nodes.

Returns
child elements. If this element has no children, returns an empty list.
See also
Node.ChildNodes()

◆ ClassName()

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.ClassName ( )
inlinevirtual

Gets the literal value of this element's "class" attribute, which may include multiple class names, space separated.

Gets the literal value of this element's "class" attribute, which may include multiple class names, space separated. (E.g. on

class="header gray">

returns, "header gray")

Returns
The literal class attribute, or empty string if no class attribute set.

◆ ClassNames() [1/2]

virtual ICollection iText.StyledXmlParser.Jsoup.Nodes.Element.ClassNames ( )
inlinevirtual

Get all of the element's class names.

Get all of the element's class names. E.g. on element

, returns a set of two elements "header", "gray" . Note that modifications to this set are not pushed to the backing class attribute; use the ClassNames(System.Collections.Generic.ICollection) method to persist them.

Returns
set of classnames, empty if no class attribute

◆ ClassNames() [2/2]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.ClassNames ( ICollection< String >  classNames )
inlinevirtual

Set the element's class attribute to the supplied class names.

Parameters
classNames set of classes
Returns
this element, for chaining

◆ Clone()

override Object iText.StyledXmlParser.Jsoup.Nodes.Element.Clone ( )
inlinevirtual

Create a stand-alone, deep copy of this node, and all of its children.

Create a stand-alone, deep copy of this node, and all of its children. The cloned node will have no siblings or parent node. As a stand-alone object, any changes made to the clone or any of its children will not impact the original node.

The cloned node may be adopted into another Document or node structure using Element.AppendChild(Node)

Returns
stand-alone cloned node

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ CssSelector()

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.CssSelector ( )
inlinevirtual

Get a CSS selector that will uniquely select this element.

Get a CSS selector that will uniquely select this element.

If the element has an ID, returns #id; otherwise returns the parent (if any) CSS selector, followed by '>' , followed by a unique selector for the element (tag.class.class:nth-child(n)).

Returns
the CSS Path that can be used to retrieve the element in a selector.

◆ Data()

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.Data ( )
inlinevirtual

Get the combined data of this element.

Get the combined data of this element. Data is e.g. the inside of a script tag.

Returns
the data, or empty string if none
See also
DataNodes()

◆ DataNodes()

virtual IList<DataNode> iText.StyledXmlParser.Jsoup.Nodes.Element.DataNodes ( )
inlinevirtual

Get this element's child data nodes.

Get this element's child data nodes. The list is unmodifiable but the data nodes may be manipulated.

This is effectively a filter on Node.ChildNodes() to get Data nodes.

Returns
child data nodes. If this element has no data nodes, returns an empty list.
See also
Data()

◆ Dataset()

virtual IDictionary iText.StyledXmlParser.Jsoup.Nodes.Element.Dataset ( )
inlinevirtual

Get this element's HTML5 custom data attributes.

Get this element's HTML5 custom data attributes. Each attribute in the element that has a key starting with "data-" is included the dataset.

E.g., the element

... has the dataset package=jsoup, language=java

This map is a filtered view of the element's attribute map. Changes to one map (add, remove, update) are reflected in the other map.

You can find elements that have data attributes using the [^data-] attribute key prefix selector.

Returns
a map of key=value custom data attributes.

◆ ElementSiblingIndex()

virtual int iText.StyledXmlParser.Jsoup.Nodes.Element.ElementSiblingIndex ( )
inlinevirtual

Get the list index of this element in its element sibling list.

Get the list index of this element in its element sibling list. I.e. if this is the first element sibling, returns 0.

Returns
position in element sibling list

◆ Empty()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Empty ( )
inlinevirtual

Remove all of the element's child nodes.

Remove all of the element's child nodes. Any attributes are left as-is.

Returns
this element

◆ FirstElementSibling()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.FirstElementSibling ( )
inlinevirtual

Gets the first element sibling of this element.

Returns
the first sibling that is an element (aka the parent's first element child)

◆ GetAllElements()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetAllElements ( )
inlinevirtual

Find all elements under this element (including self, and children of children).

Returns
all elements

◆ GetElementById()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementById ( String  id )
inlinevirtual

Find an element by ID, including or under this element.

Find an element by ID, including or under this element.

Note that this finds the first matching ID, starting with this element. If you search down from a different starting point, it is possible to find a different element by ID. For unique element by ID within a Document, use GetElementById(System.String)

Parameters
id The ID to search for.
Returns
The first matching element by ID, starting with this element, or null if none found.

◆ GetElementsByAttribute()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttribute ( String  key )
inlinevirtual

Find elements that have a named attribute set.

Find elements that have a named attribute set. Case insensitive.

Parameters
key name of the attribute, e.g. href
Returns
elements that have this attribute, empty if none

◆ GetElementsByAttributeStarting()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeStarting ( String  keyPrefix )
inlinevirtual

Find elements that have an attribute name starting with the supplied prefix.

Find elements that have an attribute name starting with the supplied prefix. Use data- to find elements that have HTML5 datasets.

Parameters
keyPrefix name prefix of the attribute e.g. data-
Returns
elements that have attribute names that start with with the prefix, empty if none.

◆ GetElementsByAttributeValue()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValue ( String  key,
String  value 
)
inlinevirtual

Find elements that have an attribute with the specific value.

Find elements that have an attribute with the specific value. Case insensitive.

Parameters
key name of the attribute
value value of the attribute
Returns
elements that have this attribute with this value, empty if none

◆ GetElementsByAttributeValueContaining()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueContaining ( String  key,
String  match 
)
inlinevirtual

Find elements that have attributes whose value contains the match string.

Find elements that have attributes whose value contains the match string. Case insensitive.

Parameters
key name of the attribute
match substring of value to search for
Returns
elements that have attributes containing this text

◆ GetElementsByAttributeValueEnding()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueEnding ( String  key,
String  valueSuffix 
)
inlinevirtual

Find elements that have attributes that end with the value suffix.

Find elements that have attributes that end with the value suffix. Case insensitive.

Parameters
key name of the attribute
valueSuffix end of the attribute value
Returns
elements that have attributes that end with the value suffix

◆ GetElementsByAttributeValueMatching() [1/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueMatching ( String  key,
Regex  pattern 
)
inlinevirtual

Find elements that have attributes whose values match the supplied regular expression.

Parameters
key name of the attribute
pattern compiled regular expression to match against attribute values
Returns
elements that have attributes matching this regular expression

◆ GetElementsByAttributeValueMatching() [2/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueMatching ( String  key,
String  regex 
)
inlinevirtual

Find elements that have attributes whose values match the supplied regular expression.

Parameters
key name of the attribute
regex regular expression to match against attribute values. You can use embedded flags (such as (?i) and (?m) to control regex options.
Returns
elements that have attributes matching this regular expression

◆ GetElementsByAttributeValueNot()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueNot ( String  key,
String  value 
)
inlinevirtual

Find elements that either do not have this attribute, or have it with a different value.

Find elements that either do not have this attribute, or have it with a different value. Case insensitive.

Parameters
key name of the attribute
value value of the attribute
Returns
elements that do not have a matching attribute

◆ GetElementsByAttributeValueStarting()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByAttributeValueStarting ( String  key,
String  valuePrefix 
)
inlinevirtual

Find elements that have attributes that start with the value prefix.

Find elements that have attributes that start with the value prefix. Case insensitive.

Parameters
key name of the attribute
valuePrefix start of attribute value
Returns
elements that have attributes that start with the value prefix

◆ GetElementsByClass()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByClass ( String  className )
inlinevirtual

Find elements that have this class, including or under this element.

Find elements that have this class, including or under this element. Case insensitive.

Elements can have multiple classes (e.g.

. This method checks each class, so you can find the above with el.getElementsByClass("header");

Parameters
className the name of the class to search for.
Returns
elements with the supplied class name, empty if none
See also
HasClass(System.String), ClassNames()

◆ GetElementsByIndexEquals()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByIndexEquals ( int  index )
inlinevirtual

Find elements whose sibling index is equal to the supplied index.

Parameters
index 0-based index
Returns
elements equal to index

◆ GetElementsByIndexGreaterThan()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByIndexGreaterThan ( int  index )
inlinevirtual

Find elements whose sibling index is greater than the supplied index.

Parameters
index 0-based index
Returns
elements greater than index

◆ GetElementsByIndexLessThan()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByIndexLessThan ( int  index )
inlinevirtual

Find elements whose sibling index is less than the supplied index.

Parameters
index 0-based index
Returns
elements less than index

◆ GetElementsByTag()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsByTag ( String  tagName )
inlinevirtual

Finds elements, including and recursively under this element, with the specified tag name.

Parameters
tagName The tag name to search for (case insensitively).
Returns
a matching unmodifiable list of elements. Will be empty if this element and none of its children match.

◆ GetElementsContainingOwnText()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsContainingOwnText ( String  searchText )
inlinevirtual

Find elements that directly contain the specified string.

Find elements that directly contain the specified string. The search is case insensitive. The text must appear directly in the element, not in any of its descendants.

Parameters
searchText to look for in the element's own text
Returns
elements that contain the string, case insensitive.
See also
OwnText()

◆ GetElementsContainingText()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsContainingText ( String  searchText )
inlinevirtual

Find elements that contain the specified string.

Find elements that contain the specified string. The search is case insensitive. The text may appear directly in the element, or in any of its descendants.

Parameters
searchText to look for in the element's text
Returns
elements that contain the string, case insensitive.
See also
Text()

◆ GetElementsMatchingOwnText() [1/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsMatchingOwnText ( Regex  pattern )
inlinevirtual

Find elements whose own text matches the supplied regular expression.

Parameters
pattern regular expression to match text against
Returns
elements matching the supplied regular expression.
See also
OwnText()

◆ GetElementsMatchingOwnText() [2/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsMatchingOwnText ( String  regex )
inlinevirtual

Find elements whose text matches the supplied regular expression.

Parameters
regex regular expression to match text against. You can use embedded flags (such as (?i) and (?m) to control regex options.
Returns
elements matching the supplied regular expression.
See also
OwnText()

◆ GetElementsMatchingText() [1/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsMatchingText ( Regex  pattern )
inlinevirtual

Find elements whose text matches the supplied regular expression.

Parameters
pattern regular expression to match text against
Returns
elements matching the supplied regular expression.
See also
Text()

◆ GetElementsMatchingText() [2/2]

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.GetElementsMatchingText ( String  regex )
inlinevirtual

Find elements whose text matches the supplied regular expression.

Parameters
regex regular expression to match text against. You can use embedded flags (such as (?i) and (?m) to control regex options.
Returns
elements matching the supplied regular expression.
See also
Text()

◆ HasClass()

virtual bool iText.StyledXmlParser.Jsoup.Nodes.Element.HasClass ( String  className )
inlinevirtual

Tests if this element has a class.

Tests if this element has a class. Case insensitive.

Parameters
className name of class to check for
Returns
true if it does, false if not

◆ HasText()

virtual bool iText.StyledXmlParser.Jsoup.Nodes.Element.HasText ( )
inlinevirtual

Test if this element has any text content (that is not just whitespace).

Returns
true if element has non-blank text content.

◆ Html() [1/3]

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.Html ( )
inlinevirtual

Retrieves the element's inner HTML.

Retrieves the element's inner HTML. E.g. on a

with one empty

, would return

. (Whereas Node.OuterHtml() would return

.)

Returns
String of HTML.
See also
Node.OuterHtml()

◆ Html() [2/3]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Html ( String  html )
inlinevirtual

Set this element's inner HTML.

Set this element's inner HTML. Clears the existing HTML first.

Parameters
html HTML to parse and set into this element
Returns
this element
See also
Append(System.String)

◆ Html() [3/3]

override StringBuilder iText.StyledXmlParser.Jsoup.Nodes.Element.Html ( StringBuilder  appendable )
inlinevirtual

Write this node and its children to the given System.Text.StringBuilder .

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Id()

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.Id ( )
inlinevirtual

Get the id attribute of this element.

Returns
The id attribute, if present, or an empty string if not.

◆ InsertChild()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.InsertChild ( int  index,
iText.StyledXmlParser.Jsoup.Nodes.Node  child 
)
inlinevirtual

Inserts the given child node into this element at the specified index.

Inserts the given child node into this element at the specified index. Current node will be shifted to the right. The inserted nodes will be moved from their current parent. To prevent moving, copy the node first.

Parameters
index 0-based index to insert children at. Specify 0 to insert at the start, -1 at the end
child child node to insert
Returns
this element, for chaining.

◆ InsertChildren< _T0 >()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.InsertChildren< _T0 > ( int  index,
ICollection< _T0 >  children 
)
inlinevirtual

Inserts the given child nodes into this element at the specified index.

Inserts the given child nodes into this element at the specified index. Current nodes will be shifted to the right. The inserted nodes will be moved from their current parent. To prevent moving, copy the nodes first.

Parameters
index 0-based index to insert children at. Specify 0 to insert at the start, -1 at the end
children child nodes to insert
Returns
this element, for chaining.
Type Constraints
_T0  : iText.StyledXmlParser.Jsoup.Nodes.Node  

◆ IsBlock()

virtual bool iText.StyledXmlParser.Jsoup.Nodes.Element.IsBlock ( )
inlinevirtual

Test if this element is a block-level element.

Test if this element is a block-level element. (E.g.

== true or an inline element

== false ).

Returns
true if block, false if not (and thus inline)

◆ LastElementSibling()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.LastElementSibling ( )
inlinevirtual

Gets the last element sibling of this element

Returns
the last sibling that is an element (aka the parent's last element child)

◆ NextElementSibling()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.NextElementSibling ( )
inlinevirtual

Gets the next sibling element of this element.

Gets the next sibling element of this element. E.g., if a div contains two p s, the nextElementSibling of the first p is the second p

This is similar to Node.NextSibling() , but specifically finds only Elements

Returns
the next element, or null if there is no next element
See also
PreviousElementSibling()

◆ NodeName()

override String iText.StyledXmlParser.Jsoup.Nodes.Element.NodeName ( )
inlinevirtual

Get the node name of this node.

Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof).

Returns
node name

Implements iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ OwnText()

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.OwnText ( )
inlinevirtual

Gets the text owned by this element only; does not get the combined text of all children.

Gets the text owned by this element only; does not get the combined text of all children.

For example, given HTML

Hello there now!

, p.ownText() returns "Hello now!" , whereas p.text() returns "Hello there now!"Note that the text within the b element is not returned, as it is not a direct child of the p element.

Returns
unencoded text, or empty string if none.
See also
Text(), TextNodes()

◆ Parent()

sealed override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.Parent ( )
inlinevirtual

Gets this node's parent node.

Returns
parent node; or null if no parent.

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.

◆ Parents()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.Parents ( )
inlinevirtual

Get this element's parent and ancestors, up to the document root.

Returns
this element's stack of parents, closest first.

◆ Prepend()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Prepend ( String  html )
inlinevirtual

Add inner HTML into this element.

Add inner HTML into this element. The supplied HTML will be parsed, and each node prepended to the start of the element's children.

Parameters
html HTML to add inside this element, before the existing HTML
Returns
this element
See also
Html(System.String)

◆ PrependChild()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.PrependChild ( iText.StyledXmlParser.Jsoup.Nodes.Node  child )
inlinevirtual

Add a node to the start of this element's children.

Parameters
child node to add.
Returns
this element, so that you can add more child nodes or elements.

◆ PrependElement()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.PrependElement ( String  tagName )
inlinevirtual

Create a new element by tag name, and add it as the first child.

Parameters
tagName the name of the tag (e.g. div ).
Returns
the new element, to allow you to add content to it, e.g.: parent.prependElement("h1").attr("id", "header").text("Welcome");

◆ PrependText()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.PrependText ( String  text )
inlinevirtual

Create and prepend a new TextNode to this element.

Parameters
text the unencoded text to add
Returns
this element

◆ PreviousElementSibling()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.PreviousElementSibling ( )
inlinevirtual

Gets the previous element sibling of this element.

Returns
the previous element, or null if there is no previous element
See also
NextElementSibling()

◆ RemoveClass()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.RemoveClass ( String  className )
inlinevirtual

Remove a class name from this element's class attribute.

Parameters
className class name to remove
Returns
this element

◆ Select()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.Select ( String  cssQuery )
inlinevirtual

Find elements that match the iText.StyledXmlParser.Jsoup.Select.Selector CSS query, with this element as the starting context. Matched elements may include this element, or any of its children.

This method is generally more powerful to use than the DOM-type getElementBy* methods, because multiple filters can be combined, e.g.:

  • el.select("a[href]")
    • finds links ( a tags with href attributes)
  • el.select("a[href*=example.com]")
    • finds links pointing to example.com (loosely)

See the query syntax documentation in iText.StyledXmlParser.Jsoup.Select.Selector

Parameters
cssQuery a iText.StyledXmlParser.Jsoup.Select.Selector CSS-like query
Returns
elements that match the query (empty if none match)
See also
iText.StyledXmlParser.Jsoup.Select.Selector
Exceptions
iText.StyledXmlParser.Jsoup.Select.Selector.SelectorParseException (unchecked) on an invalid CSS query.

◆ SiblingElements()

virtual Elements iText.StyledXmlParser.Jsoup.Nodes.Element.SiblingElements ( )
inlinevirtual

Get sibling elements.

Get sibling elements. If the element has no sibling elements, returns an empty list. An element is not a sibling of itself, so will not be included in the returned list.

Returns
sibling elements

◆ Tag()

virtual iText.StyledXmlParser.Jsoup.Parser.Tag iText.StyledXmlParser.Jsoup.Nodes.Element.Tag ( )
inlinevirtual

Get the Tag for this element.

Returns
the tag object

◆ TagName() [1/2]

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.TagName ( )
inlinevirtual

Get the name of the tag for this element.

Get the name of the tag for this element. E.g. div

Returns
the tag name

◆ TagName() [2/2]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.TagName ( String  tagName )
inlinevirtual

Change the tag of this element.

Change the tag of this element. For example, convert a to a

with el.tagName("div");

Parameters
tagName new tag name for this element
Returns
this element, for chaining

◆ Text() [1/2]

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.Text ( )
inlinevirtual

Gets the combined text of this element and all its children.

Gets the combined text of this element and all its children. Whitespace is normalized and trimmed.

For example, given HTML

Hello there now!

, p.text() returns "Hello there now!"

Returns
unencoded text, or empty string if none.
See also
OwnText(), TextNodes()

◆ Text() [2/2]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Text ( String  text )
inlinevirtual

Set the text of this element.

Set the text of this element. Any existing contents (text or elements) will be cleared

Parameters
text unencoded text
Returns
this element

Reimplemented in iText.StyledXmlParser.Jsoup.Nodes.Document.

◆ TextNodes()

virtual IList<TextNode> iText.StyledXmlParser.Jsoup.Nodes.Element.TextNodes ( )
inlinevirtual

Get this element's child text nodes.

Get this element's child text nodes. The list is unmodifiable but the text nodes may be manipulated.

This is effectively a filter on Node.ChildNodes() to get Text nodes.

Returns

child text nodes. If this element has no text nodes, returns an empty list.

For example, with the input HTML:

One Two Three
Four

with the p element selected:

  • p.text() = "One Two Three Four"
  • p.ownText() = "One Three Four"
  • p.children() = Elements[,
    ]
  • p.childNodes() = List<Node>["One ", , " Three ",
    , " Four"]
  • p.textNodes() = List<TextNode>["One ", " Three ", " Four"]

◆ ToggleClass()

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.ToggleClass ( String  className )
inlinevirtual

Toggle a class name on this element's class attribute: if present, remove it; otherwise add it.

Parameters
className class name to toggle
Returns
this element

◆ Val() [1/2]

virtual String iText.StyledXmlParser.Jsoup.Nodes.Element.Val ( )
inlinevirtual

Get the value of a form element (input, textarea, etc).

Returns
the value of the form element, or empty string if not set.

◆ Val() [2/2]

virtual iText.StyledXmlParser.Jsoup.Nodes.Element iText.StyledXmlParser.Jsoup.Nodes.Element.Val ( String  value )
inlinevirtual

Set the value of a form element (input, textarea, etc).

Parameters
value value to set
Returns
this element (for chaining)

◆ Wrap()

override iText.StyledXmlParser.Jsoup.Nodes.Node iText.StyledXmlParser.Jsoup.Nodes.Element.Wrap ( String  html )
inlinevirtual

Wrap the supplied HTML around this element.

Parameters
html HTML to wrap around this element, e.g.
. Can be arbitrarily deep.
Returns
this element, for chaining.

Reimplemented from iText.StyledXmlParser.Jsoup.Nodes.Node.