How to pass all XML attributes from source to output in Dataweave 2.0

How to pass all XML attributes from source to output in Dataweave 2.0


Below is an example that includes more than one attribute in one element. In the below example, a book is an element that has id, genre, type as attributes. It's quite tricky to pass all the attributes from the input source to output with XML messages in Dataweave 2.0. This article gives you an easy way to pass all the XML attributes in Dataweave 2.0

2tEe8hs.png (1876×571)

Dataweave Code:
%dw 2.0
output application/xml
---
{
Result: {
(payload.catalog.*book map ( books , indexOfbooks ) -> {
bookInfo @((books.@)): {
item: books.item
}
})
}
}

Post a Comment

0 Comments