XML Query All
XML Query All
Section titled “XML Query All”Type: xml-query-all · Package: XML Activities v1.1.1 · Output: List
Evaluates an XPath expression and returns all the matching values as a list. Use it when the XML has several repeated elements (invoice lines, products, records) and you want to go through all of them.
How it works
Section titled “How it works”Applies the xpath to the xml and returns the list of texts of every match (elements, attributes or text nodes), in document order. The text of each match is computed as in XML Query Text: an element with children gives the text of all its descendants, joined. See XPath.
If the XPath computes a single value (count(//Item), sum(//Total)), the list holds one element with that value as text (["3"]).
The document’s namespace prefixes work directly (//cac:InvoiceLine/cbc:ID) and the default namespace is written with d:. See Namespaces. If nothing matches and the document has a default namespace, the log reminds you to use that prefix.
It doesn’t modify the input xml.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
xml | string | — | The XML text (from Read XML or another query). Also an embedded XML, like the content of a CDATA. |
xpath | string | — | The XPath expression, e.g. //Product/Code or //cac:InvoiceLine/cbc:LineExtensionAmount. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
namespaces | Dictionary | — | Extra prefixes, or prefixes that override the document’s (prefix → URI). The ones declared in the XML are registered automatically. Since 1.1.0. |
defaultPrefix | string | "d" | Prefix used in the XPath for the document’s default namespace (xmlns="…"). Empty means "d". Since 1.1.0. |
Output
Section titled “Output”Returns a List of string, one entry per match, in document order. If there is none, an empty list (not null): you can pass it straight to For Each without checking it.
Values are always text: to add up amounts, convert them with an expression (e.g. toNumber(value)).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'xml' is required. / 'xpath' is required. | The parameter was left empty or its expression returned null. |
The XPath expression «…» is not valid: … | Wrong syntax in the XPath. |
The prefix 'x:' is not declared in the XML or in 'namespaces'. Available prefixes: …. | Use one of the listed prefixes or define it in namespaces. |
| XML parser / DTD / size / nesting message | The xml is not valid or exceeds the limits. See Common package errors. |
Example
Section titled “Example”Read XML path = filePath → output: xmlXML Query All xml = xml xpath = "//Product/Code" → output: codesLog message = "Products: " + count(codes)For Each items = codes itemVariable = code └─ activities: ... process each code ...The line amounts of a UBL invoice:
XML Query All xml = invoice xpath = "//cac:InvoiceLine/cbc:LineExtensionAmount" → output: amountsRelated activities
Section titled “Related activities”- XML Query Text — only the first value.
- XML to Dictionary — the full lines as a list of dictionaries.
- For Each — go through the results.