Contact Free trial Login

Include XML Namespaces

This DataWeave example defines different namespaces in the header and then references them on each tag.

This example uses:

  • namespace definitions in the header.

  • @ to define other attributes in an XML element.

%dw 2.0
output application/xml
ns orders
ns stores
    orders#orders: {
        stores#shipNodeId: "SF01",
        stores#shipNodeId @(shipsVia:"LA01"): "NY03"
<?xml version='1.0' encoding='US-ASCII'?>
  <po:order xmlns:po="">
    <store:shipNodeId xmlns:store="">SF01</store:shipNodeId>
    <store:shipNodeId xmlns:store="" shipsVia="LA01">NY03</store:shipNodeId>

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub