Description:

Extracts HTML element values from the incoming flowfile’s content using a CSS selector. The incoming HTML is first converted into a HTML Document Object Model so that HTML elements may be selected in the similar manner that CSS selectors are used to apply styles to HTML. The resulting HTML DOM is then “queried” using the user defined CSS selector string. The result of “querying” the HTML DOM may produce 0-N results. If no results are found the flowfile will be transferred to the “element not found” relationship to indicate so to the end user. If N results are found a new flowfile will be created and emitted for each result. The query result will either be placed in the content of the new flowfile or as an attribute of the new flowfile. By default the result is written to an attribute. This can be controlled by the “Destination” property. Resulting query values may also have data prepended or appended to them by setting the value of property “Prepend Element Value” or “Append Element Value”. Prepended and appended values are treated as string values and concatenated to the result retrieved from the HTML DOM query operation. A more thorough reference for the CSS selector syntax can be found at “http://jsoup.org/apidocs/org/jsoup/select/Selector.html”

Tags:

get, html, dom, css, element

Properties:

In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values, and whether a property supports the Expression Language Guide.

Name Default Value Allowable Values Description
URL Base URL for the HTML page being parsed.
CSS Selector CSS selector syntax string used to extract the desired HTML element(s).
Supports Expression Language: true
HTML Character Encoding UTF-8 Character encoding of the input HTML
Output Type HTML * HTML
* Text
* Attribute
* Data
Controls the type of DOM value that is retrieved from the HTML element.
Destination flowfile-attribute * flowfile-attribute
* flowfile-content
Control if element extracted is written as a flowfile attribute or as flowfile content.
Prepend Element Value Prepends the specified value to the resulting Element
Supports Expression Language: true
Append Element Value Appends the specified value to the resulting Element
Supports Expression Language: true
Attribute Name When getting the value of a HTML element attribute this value is used as the key to determine which attribute on the selected element should be retrieved. This value is used when the "Output Type" is set to "Attribute"
Supports Expression Language: true

Relationships:

Name Description
element not found Element could not be found in the HTML document. The original HTML input will remain in the flowfile content unchanged. Relationship 'original' will not be invoked in this scenario.
original The original HTML input
invalid html The input HTML syntax is invalid
success Successfully parsed HTML element

Reads Attributes:

None specified.

Writes Attributes:

Name Description
HTMLElement Flowfile attribute where the element result parsed from the HTML using the CSS selector syntax are placed if the destination is a flowfile attribute.

See Also:

ModifyHTMLElement,PutHTMLElement