doc:xpath

March 26, 2020

Name

doc:xpath — Perform an XPath query

Synopsis

require('xml');

doc:xpath(query, [contextnode]);

query: string
contextnode: string (optional)

Description

This function performs an XPath query and returns an iterator over the resultant set of nodes. You may specify an optional node from the same document to use as context for the XPath query. Note: If you include a context node you must enclose it in square brackets.

...
for node in doc:xpath("//item") do
  print(node:name())
end

See Also

xml.parsexml