pyio.xml_find - pytha-3d-cad/pytha-lua-api GitHub Wiki

Finds the first xml node inside an xml tree that matches the given location path

pyio.xml_find(start_element, path, namespaces) 
start_element:xml_find(path, namespaces) 
Parameter Type Description
start_element xml_document or xml_element The xml node from where to navigate the path
path string Relative path. The syntax allows a subset of XPath 1.0, see below
namespaces { prefix = namespace_uri, ... } Optional. A table that matches the namespace-prefixes used in the path parameter to actual namespace URI names

Return value

Type Description
xml_element or string or nil Depending which type of xml node is identified by the path, the function may return an xml_element or a string. If there's no match, it returns nil

Options for path

The path syntax supports a subset of the XPath 1.0 syntax for abbreviated location paths. Individual path steps can be delimited by either one slash / or two slashes // where (broadly speaking) the former identifies child-nodes and the latter identifies any descendant.

The segments of the path can use the following XPath constructs

Construct Description
* Any xml element
abc An xml element named "abc"
pre:abc An xml element named "abc" that lives in the namespace identified by namespaces[pre]
text() Any text whitespace or CDATA. Returns a string if successful
@attr An xml attribute name "attr". Returns the attribute value as a string if successful
...[5] The fifth node that matches. Only integer index predicates are supported

Version Support:

Minimum PYTHA Version: V26

See also:

pyio, pyio.parse_xml