XPath

Description

Extracts part of an XML document using an XPath expression.

Syntax

XPath(xml_string, xpath_string[, cache_xml_doc[, namespaces[, decode_xml]]])

Arguments

  xml_string  - string 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"/>

  decode_xml (optional) - boolean flag that defines if XML entities should be decoded. True by default.

Examples

XPath('<customer><firstname>John</firstname><lastname>Doe</lastname></customer>','/customer/firstname')returns: John

Return value datatype

String

Impact of null value

If any of the inputs is null, returns null.