Skip to content

xpath

io · scripts/io/xpath.m

XPATH  Evaluate an XPath 1.0 expression against XML (MATLAB-compatible).

  RESULT = XPATH (SOURCE, EXPRESSION)
  RESULT = XPATH (SOURCE, EXPRESSION, RESULTTYPE)

  SOURCE is a local XML file name, a URL, or an org.w3c.dom.Node (for
  example the Document returned by XMLREAD with XMLEngine "jaxp").

  EXPRESSION is an XPath 1.0 expression as a character vector or string
  scalar.

  RESULTTYPE selects the return class and matches
  matlab.io.xml.xpath.EvalResultType:
    'string'   (default)  - string scalar (empty string if no match)
    'number'              - double
    'boolean'             - logical
    'node'                - single org.w3c.dom.Node, or [] if none
    'nodeset'             - cell row of org.w3c.dom.Node

  MATLAB R2026a exposes XPath via matlab.io.xml.xpath.Evaluator rather
  than a free function.  Nexus provides XPATH as the core entry point
  with the same expression / result-type contract, evaluated with the
  bundled Java XPath engine against the JAXP DOM that XMLREAD returns
  by default.