I need to compare an XML file with that of Json response. Below is just a short version of original xml file, JSON and XML have different attribute names because of which i cannot compare them directly. I need to call function to format xml so that it can be compared with json. During this process, I am getting the error Cannot cast java.util.LinkedHashMap to java.util.List
after running below code.
* xml list = $Test1/Body
* print list
* def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
* def fun = function(x){ return { code: xpath(x, '/Body/code') } }
* def temp = karate.map(list, fun)
* print temp
Test1 is an xml file containing below sample data;
<ns9:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns5:plan">
<ns4:code>XPBSMWAT</ns4:code>
</ns9:Body>
This is a simpler version of XML data; my actual xml file is bigger.