Skip to content
LambogeniusDocs

Compose using Liquid for Azure Logic Apps

XML and XPath

Read XML content with XmlValue and XmlValues, namespace prefixes, and what XPath may select.

Service provider/serviceProviders/lamboLiquidComposeOperation ComposeLiquid, shown in the designer as Compose using Liquid.

XmlValue and XmlValues

With "inputFormat": "xml", content is the XML document. Read it with XPath:

{
  "invoiceNumber": {{ content | XmlValue: '/inv:Invoice/cbc:ID' | ToJson }},
  "currency": {{ content | XmlValue: '/inv:Invoice/cbc:DocumentCurrencyCode' | ToJson }},
  "amountCurrency": {{ content | XmlValue: '/inv:Invoice/cac:LegalMonetaryTotal/cbc:PayableAmount/@currencyID' | ToJson }},
  "lineIds": {{ content | XmlValues: '/inv:Invoice/cac:InvoiceLine/cbc:ID' | ToJson }},
  "lineCount": {{ content | XmlValues: '/inv:Invoice/cac:InvoiceLine' | Size }}
}
"inputFormat": "xml",
"content": "@{triggerBody()}",
"xmlNamespaces": {
  "inv": "urn:oasis:names:specification:ubl:schema:xsd:Invoice-2",
  "cac": "urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2",
  "cbc": "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
}
  • XmlValue returns the text of the first match, or null; XmlValues returns every match as a list, or an empty list.
  • Every namespace needs a prefix in xmlNamespaces, the default namespace too. Elements without a namespace, such as a SOAP Fault's faultcode, are named without one.
  • Node selections only: elements, attributes and text. Expressions that return a number or a string, such as count(), are refused; use XmlValues: '…' | Size.
  • Limits: 10,000 selected nodes; DTDs are refused with InvalidInputXml.
Text out

To write XML or SOAP, use "outputFormat": "text" and Escape every value. Sample 06 builds a SOAP envelope and reads the response or Fault back.