Extract HTML Text | EXTRACT_HTML_TEXT

Syntax

EXTRACT_HTML_TEXT( [html], [selector], [returnList = false] )

Parameters

html
An HTML string

selector
A CSS selector to query the HTML document

returnList optional
When TRUE, all matching results are returned as a LIST in the order they are found in the document. When FALSE, only the first found result is returned.

Return Value

The TEXT of the matched element

Description

Query an HTML string to extract the inner text of the matched element.

Examples

# VALUE is '<!doctype HTML><html><body><div id="mydiv" someprop="hello there"><p>This is an example paragraph</p><p>This is <i>another</i> example paragraph</p></div></body></html>'
EXTRACT_HTML_TEXT(VALUE, "#mydiv")
# Returns 'This is an example paragraphThis is another example paragraph'
# VALUE is '<!doctype HTML><html><body><div id="mydiv" someprop="hello there"><p>This is an example paragraph</p><p>This is <i>another</i> example paragraph</p></div></body></html>'
EXTRACT_HTML_TEXT(VALUE, "#mydiv p", true)
# Returns ['This is an example paragraph','This is another example paragraph']
# VALUE is '<!doctype HTML><html><body><div id="mydiv" someprop="hello there"><p>This is an example paragraph</p><p>This is <i>another</i> example paragraph</p></div></body></html>'
EXTRACT_HTML_TEXT(VALUE, "#mydiv p span")
# Returns NULL