AnsweredAssumed Answered

How to extract and map CDATA data elements from an XML message

Question asked by amudhavani.shanthosh181426 on Aug 16, 2018
Latest reply on Aug 16, 2018 by amudhavani.shanthosh181426

Hi,

 

I am making a SOAP client call, and in the SOAP response, I am getting CDATA structure under "<CheckDetail>" tag as shown below. 

Inside this CDATA XML, "DetailLine" is a repeating structure. I need to parse this "DetailLine" and extract values.

 

Example : I need to check whether "DetailType" inside this "DetailLine" is "DtlDscAllocType" or not. If yes, need to "itemLink" value under this "DetailLine".

 

I tried replacing "&lt;" with < and "&gt;" with >. And created a profile with the response format and tried to parsed. But in the place "<CheckDetail><?xml version="1.0" encoding="utf-16"?>" was getting error "Unable to create XML files from data, the document may not be well-formed xml ; Caused by: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs. at [row,col {unknown-source}]: [8,22]". 

 

In the data process shape, when I tried to search and replace "<CheckDetail><?xml version="1.0" encoding="utf-16"?>" with "<CheckDetail>, it is not successful and getting the same result. 

 

Can someone please provide inputs on how to achieve my use-case. Thanks.

 

SOAP Response with CDATA

 

<?xml version="1.0" encoding="UTF-8" standalone="no"?><GetCheckDetailResponse xmlns="http://micros-hosting.com/EGateway/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ppCheckDetailResponse>
<OperationalResult>
<Success>true</Success>
<ErrorCode>Success</ErrorCode>
<ErrorMessage>Success</ErrorMessage>
</OperationalResult>
<CheckDetail>&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;Check&gt;
&lt;Summary&gt;
&lt;DetailLines&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlMiType&lt;/DetailType&gt;
&lt;Seat&gt;0&lt;/Seat&gt;
&lt;SalesCount&gt;1&lt;/SalesCount&gt;
&lt;Total&gt;10.6900&lt;/Total&gt;
&lt;VoidLink&gt;0&lt;/VoidLink&gt;
&lt;DetailLink&gt;1&lt;/DetailLink&gt;
&lt;ParentDetailLink&gt;0&lt;/ParentDetailLink&gt;
&lt;RoundNumber&gt;1&lt;/RoundNumber&gt;
&lt;MenuItem&gt;
&lt;obj&gt;101000001&lt;/obj&gt;
&lt;/DetailLine&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlMiType&lt;/DetailType&gt;
&lt;MenuItem&gt;
&lt;obj&gt;102001012&lt;/obj&gt;
&lt;/DetailLine&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlDscType&lt;/DetailType&gt;
&lt;Seat&gt;0&lt;/Seat&gt;
&lt;SalesCount&gt;0&lt;/SalesCount&gt;
&lt;Total&gt;0&lt;/Total&gt;
&lt;VoidLink&gt;0&lt;/VoidLink&gt;
&lt;DetailLink&gt;4&lt;/DetailLink&gt;
&lt;ParentDetailLink&gt;0&lt;/ParentDetailLink&gt;
&lt;RoundNumber&gt;1&lt;/RoundNumber&gt;
&lt;Discount&gt;
&lt;obj&gt;10102&lt;/obj&gt;
&lt;Name&gt;Free Perks Bev&lt;/Name&gt;
&lt;dsc_empl&gt;0&lt;/dsc_empl&gt;
&lt;pcnt&gt;0&lt;/pcnt&gt;
&lt;dscDbId&gt;2338&lt;/dscDbId&gt;
&lt;CouponTotal&gt;0&lt;/CouponTotal&gt;
&lt;ChangeDrawerNum&gt;0&lt;/ChangeDrawerNum&gt;
&lt;auth_empl&gt;0&lt;/auth_empl&gt;
&lt;/Discount&gt;
&lt;/DetailLine&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlDscType&lt;/DetailType&gt;
&lt;Seat&gt;0&lt;/Seat&gt;
&lt;SalesCount&gt;1&lt;/SalesCount&gt;
&lt;Total&gt;-10.69&lt;/Total&gt;
&lt;VoidLink&gt;0&lt;/VoidLink&gt;
&lt;DetailLink&gt;5&lt;/DetailLink&gt;
&lt;ParentDetailLink&gt;0&lt;/ParentDetailLink&gt;
&lt;RoundNumber&gt;1&lt;/RoundNumber&gt;
&lt;Discount&gt;
&lt;obj&gt;10102&lt;/obj&gt;
&lt;Name&gt;Free Perks Bev&lt;/Name&gt;
&lt;dsc_empl&gt;0&lt;/dsc_empl&gt;
&lt;pcnt&gt;1.000000&lt;/pcnt&gt;
&lt;dscDbId&gt;2338&lt;/dscDbId&gt;
&lt;CouponTotal&gt;0&lt;/CouponTotal&gt;
&lt;ChangeDrawerNum&gt;0&lt;/ChangeDrawerNum&gt;
&lt;auth_empl&gt;0&lt;/auth_empl&gt;
&lt;/Discount&gt;
&lt;/DetailLine&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlDscAllocType&lt;/DetailType&gt;
&lt;Seat&gt;0&lt;/Seat&gt;
&lt;SalesCount&gt;0&lt;/SalesCount&gt;
&lt;Total&gt;0&lt;/Total&gt;
&lt;VoidLink&gt;0&lt;/VoidLink&gt;
&lt;DetailLink&gt;0&lt;/DetailLink&gt;
&lt;ParentDetailLink&gt;0&lt;/ParentDetailLink&gt;
&lt;RoundNumber&gt;1&lt;/RoundNumber&gt;
&lt;dsc_alloc&gt;
&lt;dscDtlLink&gt;5&lt;/dscDtlLink&gt;
&lt;alloc&gt;
&lt;DscAllocEntry&gt;
&lt;itemLink&gt;1&lt;/itemLink&gt;
&lt;subItem&gt;0&lt;/subItem&gt;
&lt;includesMiTax&gt;false&lt;/includesMiTax&gt;
&lt;amount&gt;10.69&lt;/amount&gt;
&lt;inclTax&gt;0&lt;/inclTax&gt;
&lt;VAT&gt;0&lt;/VAT&gt;
&lt;VATExt&gt;0&lt;/VATExt&gt;
&lt;/DscAllocEntry&gt;
&lt;/alloc&gt;
&lt;/dsc_alloc&gt;
&lt;/DetailLine&gt;
&lt;DetailLine&gt;
&lt;DetailType&gt;DtlExtensibilityDataType&lt;/DetailType&gt;
&lt;Seat&gt;0&lt;/Seat&gt;
&lt;SalesCount&gt;1&lt;/SalesCount&gt;
&lt;Total&gt;0&lt;/Total&gt;
&lt;VoidLink&gt;0&lt;/VoidLink&gt;
&lt;DetailLink&gt;7&lt;/DetailLink&gt;
&lt;ParentDetailLink&gt;6&lt;/ParentDetailLink&gt;
&lt;RoundNumber&gt;1&lt;/RoundNumber&gt;
&lt;extensibility_data&gt;
&lt;ExtensibilityAppName&gt;Payment:Cash:Cash&lt;/ExtensibilityAppName&gt;
&lt;ExtensibilityDataName&gt;Payment:XmlSerializer&lt;/ExtensibilityDataName&gt;
&lt;ExtensibilityDataType&gt;Micros.Payment.PayableCash, Micros.Payment, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null:1.00&lt;/ExtensibilityDataType&gt;
&lt;StringData&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&amp;lt;?micros-type Micros.Payment.PayableCash, Micros.Payment, Version=2.5.0.0, Culture=neutral, PublicKeyToken=null?&amp;gt;&amp;lt;PayableCash xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.0" Created="2018-08-16T06:41:12.0329189Z" PaymentID="086df1df-a9e4-4410-beaf-a959f421d7d5"&amp;gt;&amp;lt;PBPM&amp;gt;&amp;lt;PaymentCategory&amp;gt;Cash&amp;lt;/PaymentCategory&amp;gt;&amp;lt;PaymentType&amp;gt;Cash&amp;lt;/PaymentType&amp;gt;&amp;lt;/PBPM&amp;gt;&amp;lt;PBLI&amp;gt;1&amp;lt;/PBLI&amp;gt;&amp;lt;PBS&amp;gt;99999&amp;lt;/PBS&amp;gt;&amp;lt;PBPS&amp;gt;9&amp;lt;/PBPS&amp;gt;&amp;lt;PBNS&amp;gt;99999&amp;lt;/PBNS&amp;gt;&amp;lt;PBCF&amp;gt;&amp;lt;PaymentModule&amp;gt;&amp;lt;PaymentCategory&amp;gt;Cash&amp;lt;/PaymentCategory&amp;gt;&amp;lt;PaymentType&amp;gt;Cash&amp;lt;/PaymentType&amp;gt;&amp;lt;/PaymentModule&amp;gt;&amp;lt;Aliases&amp;gt;&amp;lt;string /&amp;gt;&amp;lt;string&amp;gt;Default&amp;lt;/string&amp;gt;&amp;lt;/Aliases&amp;gt;&amp;lt;Description&amp;gt;Default cash function. Does not override any tender/media configuration.&amp;lt;/Description&amp;gt;&amp;lt;TextId&amp;gt;Default&amp;lt;/TextId&amp;gt;&amp;lt;ConfigurationId&amp;gt;0&amp;lt;/ConfigurationId&amp;gt;&amp;lt;ConfigurationType&amp;gt;Payment&amp;lt;/ConfigurationType&amp;gt;&amp;lt;/PBCF&amp;gt;&amp;lt;PBRC&amp;gt;-1&amp;lt;/PBRC&amp;gt;&amp;lt;PBPA&amp;gt;5.9300&amp;lt;/PBPA&amp;gt;&amp;lt;PBPACI&amp;gt;31&amp;lt;/PBPACI&amp;gt;&amp;lt;PBPACC&amp;gt;0&amp;lt;/PBPACC&amp;gt;&amp;lt;PBDCCR&amp;gt;0&amp;lt;/PBDCCR&amp;gt;&amp;lt;PBCI&amp;gt;145&amp;lt;/PBCI&amp;gt;&amp;lt;PBCN&amp;gt;OLO TENDER&amp;lt;/PBCN&amp;gt;&amp;lt;PBPAc&amp;gt;Pay&amp;lt;/PBPAc&amp;gt;&amp;lt;RoundTenders&amp;gt;false&amp;lt;/RoundTenders&amp;gt;&amp;lt;Rounding&amp;gt;false&amp;lt;/Rounding&amp;gt;&amp;lt;RoundToTheTens&amp;gt;false&amp;lt;/RoundToTheTens&amp;gt;&amp;lt;Round2ndLeastSignificantDigit&amp;gt;false&amp;lt;/Round2ndLeastSignificantDigit&amp;gt;&amp;lt;RoundChangeDueDown&amp;gt;false&amp;lt;/RoundChangeDueDown&amp;gt;&amp;lt;RoundToNextDollar&amp;gt;false&amp;lt;/RoundToNextDollar&amp;gt;&amp;lt;CurrencyNumberDecimals&amp;gt;0&amp;lt;/CurrencyNumberDecimals&amp;gt;&amp;lt;PTBTA&amp;gt;5.9300&amp;lt;/PTBTA&amp;gt;&amp;lt;PTBTACI&amp;gt;0&amp;lt;/PTBTACI&amp;gt;&amp;lt;PTBTD&amp;gt;5.9300&amp;lt;/PTBTD&amp;gt;&amp;lt;PTBCT&amp;gt;0&amp;lt;/PTBCT&amp;gt;&amp;lt;PTBCTH&amp;gt;0&amp;lt;/PTBCTH&amp;gt;&amp;lt;PTBTAA&amp;gt;AssumePaidInFull&amp;lt;/PTBTAA&amp;gt;&amp;lt;PTBHALT&amp;gt;TenderedAmount&amp;lt;/PTBHALT&amp;gt;&amp;lt;PTBIHALA&amp;gt;true&amp;lt;/PTBIHALA&amp;gt;&amp;lt;PTBADC&amp;gt;true&amp;lt;/PTBADC&amp;gt;&amp;lt;PTBIPZBA&amp;gt;true&amp;lt;/PTBIPZBA&amp;gt;&amp;lt;PTBIPNBA&amp;gt;true&amp;lt;/PTBIPNBA&amp;gt;&amp;lt;PTBIPPA&amp;gt;true&amp;lt;/PTBIPPA&amp;gt;&amp;lt;PCCD&amp;gt;0&amp;lt;/PCCD&amp;gt;&amp;lt;PCTAX&amp;gt;0&amp;lt;/PCTAX&amp;gt;&amp;lt;PCCDCI&amp;gt;0&amp;lt;/PCCDCI&amp;gt;&amp;lt;ZeroAmountOkay&amp;gt;true&amp;lt;/ZeroAmountOkay&amp;gt;&amp;lt;TipAmountOkay&amp;gt;false&amp;lt;/TipAmountOkay&amp;gt;&amp;lt;/PayableCash&amp;gt;&lt;/StringData&gt;
&lt;/extensibility_data&gt;
&lt;RevCtrID&gt;746&lt;/RevCtrID&gt;
&lt;taxTotals /&gt;
&lt;TaxForgivenTotal&gt;0&lt;/TaxForgivenTotal&gt;
&lt;GuestCount&gt;0&lt;/GuestCount&gt;
&lt;CashierID&gt;0&lt;/CashierID&gt;
&lt;/DetailLine&gt;
&lt;/DetailLines&gt;
&lt;/Check&gt;</CheckDetail>
</ppCheckDetailResponse>
</GetCheckDetailResponse>

Outcomes