Extract Inner HTML | EXTRACT_INNER_HTML

Syntax

EXTRACT_INNER_HTML( [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

An HTML string

Description

Query an HTML string to extract the inner HTML 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_INNER_HTML(VALUE, "#mydiv")
# Returns '<p>This is an example paragraph</p><p>This is <i>another</i> example paragraph</p>'
# 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_INNER_HTML(VALUE, "#mydiv p", true)
# Returns ['This is an example paragraph','This is <i>another</i> 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_INNER_HTML(VALUE, "#mydiv p span")
# Returns NULL