I am having process model which scheduled to run after every hour and get XML response from external system and storing into text type pv.
XML data in nested CDT format.
Now, We want to read that XML file into Appian CDT. For reference i am giving below XML response.
<variable type="InputBO"> <paymentInfo type="PaymentBO"> <operationType type="String">CAPTURE</operationType> <channelId type="String">AAA</channelId> <paymentTypeCode type="String">BBB</paymentTypeCode> <referenceNumber type="String">ABCD145891</referenceNumber> <paymentAmount type="Decimal">515.0</paymentAmount> <paymentCurrency type="String">GBP</paymentCurrency> <paymentCardDetails type="PaymentCardDetailsBO"> </paymentInfo></variable>
Could you please help me to achieve this task? Thanks for your support in advance.(Appian version 18.1)
Discussion posts and replies are publicly visible
Hi vinodt376 ,
As Sachin Raghav (sachinr981) said there are no straight forward way to do it but you can extract each value from the xml by using xpathsnippet and set it to cdt
Sample code can help you to achieve this
load( local!data: toxml( { paymentInfo: { { operationType: "CAPTURE", channelId: "AAA", paymentTypeCode: "BBB", referenceNumber: "ABCD145891", paymentAmount: "515.0", paymentCurrency: "GBP", paymentCardDetails: null } } }, true(), "variable", null ), /* you can skip foreach if you are not dealing with multiple elements in case of single elements directly create type!cdt and xpathsnippet expression will be simply */ "/variable/*/item/operationType/text()" a!forEach( items: xpathsnippet( local!data, "/variable/*/*" ), expression: /* your cdt */ { operationType: index(xpathsnippet(fv!item,"/item/operationType/text()"),1,null()), channelId:index(xpathsnippet(fv!item,"/item/channelId/text()"),1,null()), paymentTypeCode:index(xpathsnippet(fv!item,"/item/paymentTypeCode/text()"),1,null()), referenceNumber:index(xpathsnippet(fv!item,"/item/referenceNumber/text()"),1,null()), paymentAmount:index(xpathsnippet(fv!item,"/item/paymentAmount/text()"),1,null()), paymentCurrency:index(xpathsnippet(fv!item,"/item/paymentCurrency/text()"),1,null()), paymentCardDetails:index(xpathsnippet(fv!item,"/item/paymentCardDetails/text()"),1,null()), } ) )