Extract Outer HTML | EXTRACT_OUTER_HTML
Syntax
EXTRACT_OUTER_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 stringDescription
Query an HTML string to extract the outer 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_OUTER_HTML(VALUE, "#mydiv")
# Returns '<div id="mydiv" someprop="hello there"><p>This is an example paragraph</p><p>This is <i>another</i> example paragraph</p></div>'
# 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_OUTER_HTML(VALUE, "#mydiv p", true)
# 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_OUTER_HTML(VALUE, "#mydiv p span")
# Returns NULL