Extracts part of an XML document using an XPath expression and returns a bag of all matches.


XPathToBag(xml_string, xpath_string[, cache_xml_doc[, namespaces]])


  xml_string  - string or binary expression representing a well-formed XML.

  xpath_string - string expression representing an XPath expression.

  cache_xml_doc (optional) - boolean flag cache last xml doc (better performance when using the function multiple times on the same XML doc). True by default.

  namespaces (optional)- (string) an xml element that defines namespaces for the XPath engine to use. e.g. <root xmlns:h="http://www.w3.org/TR/html4/" xmlns:f="https://www.w3schools.com/furniture"/>


XPathToBag('<products><p id="1"/><p id="2"/></products>','/products/p')returns a bag with two items: <p id="1"/> and <p id="2"/>.

Return value datatype

Bag of strings

Impact of null value

If any of the inputs is null, returns null.