How to compare XML response with Json in Karate












2















I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both.



Note that Json response parameters are is not in-order with XML response.



JSON RESPONSE



"Main": {
"Cd": "ABC",
"descriptionTxt": "Sample Main",
"type": "A",
"codeType": "P",
"dt": "2018-10-15T00:00:00-05:00",
"validity": "3",
"segment": "Personal"
},
"testList": [
{
"code": "123",
"descriptionTxt": "My Description",
"categoryCd": "DUDU"
},
{
"code": "675",
"descriptionTxt": "His Description"
},
{
"code": "345",
"descriptionTxt": "Your Description",
"categoryCd": "BH"
}
]


XML RESPONSE



<S:Body>
<ns4:code>ABC </ns4:code>
<ns5:description>Sample Main</ns5:description>
<ns5:Date>2018-10-15</ns5:Date>
<ns5:Type>A</ns5:Type>
<ns5:codeType>P</ns5:codeType>
<ns5:validity>3</ns5:validity >
<ns5:Segment>PERSONAL </ns5:Segment>
<ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>

<ns4:Test>
<ns5:code>123 </ns5:code>
<ns5:description>My Description</ns5:description>
<ns5:categoryCode>DUDU</ns5:categoryCode>
<ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
</ns4:Test>

<ns4:Test>
<ns5:code>345 </ns5:code>
<ns5:description>Your Description</ns5:description>
<ns5:categoryCode>BH</ns5:categoryCode>
</ns4:Test>

<ns4:Test>
<ns5:code>675 </ns5:code>
<ns5:description>His Description</ns5:description>
<ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
</ns4:Test>











share|improve this question





























    2















    I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both.



    Note that Json response parameters are is not in-order with XML response.



    JSON RESPONSE



    "Main": {
    "Cd": "ABC",
    "descriptionTxt": "Sample Main",
    "type": "A",
    "codeType": "P",
    "dt": "2018-10-15T00:00:00-05:00",
    "validity": "3",
    "segment": "Personal"
    },
    "testList": [
    {
    "code": "123",
    "descriptionTxt": "My Description",
    "categoryCd": "DUDU"
    },
    {
    "code": "675",
    "descriptionTxt": "His Description"
    },
    {
    "code": "345",
    "descriptionTxt": "Your Description",
    "categoryCd": "BH"
    }
    ]


    XML RESPONSE



    <S:Body>
    <ns4:code>ABC </ns4:code>
    <ns5:description>Sample Main</ns5:description>
    <ns5:Date>2018-10-15</ns5:Date>
    <ns5:Type>A</ns5:Type>
    <ns5:codeType>P</ns5:codeType>
    <ns5:validity>3</ns5:validity >
    <ns5:Segment>PERSONAL </ns5:Segment>
    <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>

    <ns4:Test>
    <ns5:code>123 </ns5:code>
    <ns5:description>My Description</ns5:description>
    <ns5:categoryCode>DUDU</ns5:categoryCode>
    <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
    </ns4:Test>

    <ns4:Test>
    <ns5:code>345 </ns5:code>
    <ns5:description>Your Description</ns5:description>
    <ns5:categoryCode>BH</ns5:categoryCode>
    </ns4:Test>

    <ns4:Test>
    <ns5:code>675 </ns5:code>
    <ns5:description>His Description</ns5:description>
    <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
    </ns4:Test>











    share|improve this question



























      2












      2








      2








      I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both.



      Note that Json response parameters are is not in-order with XML response.



      JSON RESPONSE



      "Main": {
      "Cd": "ABC",
      "descriptionTxt": "Sample Main",
      "type": "A",
      "codeType": "P",
      "dt": "2018-10-15T00:00:00-05:00",
      "validity": "3",
      "segment": "Personal"
      },
      "testList": [
      {
      "code": "123",
      "descriptionTxt": "My Description",
      "categoryCd": "DUDU"
      },
      {
      "code": "675",
      "descriptionTxt": "His Description"
      },
      {
      "code": "345",
      "descriptionTxt": "Your Description",
      "categoryCd": "BH"
      }
      ]


      XML RESPONSE



      <S:Body>
      <ns4:code>ABC </ns4:code>
      <ns5:description>Sample Main</ns5:description>
      <ns5:Date>2018-10-15</ns5:Date>
      <ns5:Type>A</ns5:Type>
      <ns5:codeType>P</ns5:codeType>
      <ns5:validity>3</ns5:validity >
      <ns5:Segment>PERSONAL </ns5:Segment>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>

      <ns4:Test>
      <ns5:code>123 </ns5:code>
      <ns5:description>My Description</ns5:description>
      <ns5:categoryCode>DUDU</ns5:categoryCode>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
      </ns4:Test>

      <ns4:Test>
      <ns5:code>345 </ns5:code>
      <ns5:description>Your Description</ns5:description>
      <ns5:categoryCode>BH</ns5:categoryCode>
      </ns4:Test>

      <ns4:Test>
      <ns5:code>675 </ns5:code>
      <ns5:description>His Description</ns5:description>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
      </ns4:Test>











      share|improve this question
















      I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both.



      Note that Json response parameters are is not in-order with XML response.



      JSON RESPONSE



      "Main": {
      "Cd": "ABC",
      "descriptionTxt": "Sample Main",
      "type": "A",
      "codeType": "P",
      "dt": "2018-10-15T00:00:00-05:00",
      "validity": "3",
      "segment": "Personal"
      },
      "testList": [
      {
      "code": "123",
      "descriptionTxt": "My Description",
      "categoryCd": "DUDU"
      },
      {
      "code": "675",
      "descriptionTxt": "His Description"
      },
      {
      "code": "345",
      "descriptionTxt": "Your Description",
      "categoryCd": "BH"
      }
      ]


      XML RESPONSE



      <S:Body>
      <ns4:code>ABC </ns4:code>
      <ns5:description>Sample Main</ns5:description>
      <ns5:Date>2018-10-15</ns5:Date>
      <ns5:Type>A</ns5:Type>
      <ns5:codeType>P</ns5:codeType>
      <ns5:validity>3</ns5:validity >
      <ns5:Segment>PERSONAL </ns5:Segment>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>

      <ns4:Test>
      <ns5:code>123 </ns5:code>
      <ns5:description>My Description</ns5:description>
      <ns5:categoryCode>DUDU</ns5:categoryCode>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
      </ns4:Test>

      <ns4:Test>
      <ns5:code>345 </ns5:code>
      <ns5:description>Your Description</ns5:description>
      <ns5:categoryCode>BH</ns5:categoryCode>
      </ns4:Test>

      <ns4:Test>
      <ns5:code>675 </ns5:code>
      <ns5:description>His Description</ns5:description>
      <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
      </ns4:Test>








      karate






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 26 '18 at 4:47









      Dijkgraaf

      7,37882744




      7,37882744










      asked Nov 25 '18 at 19:38









      Nitheesh hunsurNitheesh hunsur

      767




      767
























          1 Answer
          1






          active

          oldest

          votes


















          2














          It would have been nice if you took the time to post well-formed JSON and XML, but anyway. I'm focusing on the hard problem here, which is to map repeated XML elements to JSON, if you paste the below into a Scenario you can see it work:



          * def json = 
          """
          {
          "Main": {
          "Cd":"ABC",
          "descriptionTxt":"Sample Main",
          "type":"A",
          "codeType":"P",
          "dt":"2018-10-15T00:00:00-05:00",
          "validity":"3",
          "segment":"Personal"
          },
          "testList":[
          {
          "code":"123",
          "descriptionTxt":"My Description",
          "categoryCd":"DUDU"
          },
          {
          "code":"675",
          "descriptionTxt":"His Description"
          },
          {
          "code":"345",
          "descriptionTxt":"Your Description",
          "categoryCd":"BH"
          }
          ]
          }
          """
          * def xml =
          """
          <ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
          <ns4:Test>
          <ns5:code>123</ns5:code>
          <ns5:description>My Description</ns5:description>
          <ns5:categoryCode>DUDU</ns5:categoryCode>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>345</ns5:code>
          <ns5:description>Your Description</ns5:description>
          <ns5:categoryCode>BH</ns5:categoryCode>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>675</ns5:code>
          <ns5:description>His Description</ns5:description>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          </ns4:root>
          """
          * def list = $xml/root/Test
          * def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
          * def fun = function(x){ return { code: xpath(x, '/Test/code'), descriptionTxt: xpath(x, '/Test/description'), categoryCd: xpath(x, '/Test/categoryCode') } }
          * def temp = karate.map(list, fun)
          * print temp
          * print json.testList
          * match json.testList contains temp


          Mapping the rest of the JSON is an exercise for you. Please refer to the docs. Also see this answer for more ideas: Karate - Match two dynamic responses






          share|improve this answer
























          • Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

            – Nitheesh hunsur
            Nov 30 '18 at 7:34













          • @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

            – Peter Thomas
            Nov 30 '18 at 8:32











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471153%2fhow-to-compare-xml-response-with-json-in-karate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          It would have been nice if you took the time to post well-formed JSON and XML, but anyway. I'm focusing on the hard problem here, which is to map repeated XML elements to JSON, if you paste the below into a Scenario you can see it work:



          * def json = 
          """
          {
          "Main": {
          "Cd":"ABC",
          "descriptionTxt":"Sample Main",
          "type":"A",
          "codeType":"P",
          "dt":"2018-10-15T00:00:00-05:00",
          "validity":"3",
          "segment":"Personal"
          },
          "testList":[
          {
          "code":"123",
          "descriptionTxt":"My Description",
          "categoryCd":"DUDU"
          },
          {
          "code":"675",
          "descriptionTxt":"His Description"
          },
          {
          "code":"345",
          "descriptionTxt":"Your Description",
          "categoryCd":"BH"
          }
          ]
          }
          """
          * def xml =
          """
          <ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
          <ns4:Test>
          <ns5:code>123</ns5:code>
          <ns5:description>My Description</ns5:description>
          <ns5:categoryCode>DUDU</ns5:categoryCode>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>345</ns5:code>
          <ns5:description>Your Description</ns5:description>
          <ns5:categoryCode>BH</ns5:categoryCode>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>675</ns5:code>
          <ns5:description>His Description</ns5:description>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          </ns4:root>
          """
          * def list = $xml/root/Test
          * def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
          * def fun = function(x){ return { code: xpath(x, '/Test/code'), descriptionTxt: xpath(x, '/Test/description'), categoryCd: xpath(x, '/Test/categoryCode') } }
          * def temp = karate.map(list, fun)
          * print temp
          * print json.testList
          * match json.testList contains temp


          Mapping the rest of the JSON is an exercise for you. Please refer to the docs. Also see this answer for more ideas: Karate - Match two dynamic responses






          share|improve this answer
























          • Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

            – Nitheesh hunsur
            Nov 30 '18 at 7:34













          • @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

            – Peter Thomas
            Nov 30 '18 at 8:32
















          2














          It would have been nice if you took the time to post well-formed JSON and XML, but anyway. I'm focusing on the hard problem here, which is to map repeated XML elements to JSON, if you paste the below into a Scenario you can see it work:



          * def json = 
          """
          {
          "Main": {
          "Cd":"ABC",
          "descriptionTxt":"Sample Main",
          "type":"A",
          "codeType":"P",
          "dt":"2018-10-15T00:00:00-05:00",
          "validity":"3",
          "segment":"Personal"
          },
          "testList":[
          {
          "code":"123",
          "descriptionTxt":"My Description",
          "categoryCd":"DUDU"
          },
          {
          "code":"675",
          "descriptionTxt":"His Description"
          },
          {
          "code":"345",
          "descriptionTxt":"Your Description",
          "categoryCd":"BH"
          }
          ]
          }
          """
          * def xml =
          """
          <ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
          <ns4:Test>
          <ns5:code>123</ns5:code>
          <ns5:description>My Description</ns5:description>
          <ns5:categoryCode>DUDU</ns5:categoryCode>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>345</ns5:code>
          <ns5:description>Your Description</ns5:description>
          <ns5:categoryCode>BH</ns5:categoryCode>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>675</ns5:code>
          <ns5:description>His Description</ns5:description>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          </ns4:root>
          """
          * def list = $xml/root/Test
          * def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
          * def fun = function(x){ return { code: xpath(x, '/Test/code'), descriptionTxt: xpath(x, '/Test/description'), categoryCd: xpath(x, '/Test/categoryCode') } }
          * def temp = karate.map(list, fun)
          * print temp
          * print json.testList
          * match json.testList contains temp


          Mapping the rest of the JSON is an exercise for you. Please refer to the docs. Also see this answer for more ideas: Karate - Match two dynamic responses






          share|improve this answer
























          • Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

            – Nitheesh hunsur
            Nov 30 '18 at 7:34













          • @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

            – Peter Thomas
            Nov 30 '18 at 8:32














          2












          2








          2







          It would have been nice if you took the time to post well-formed JSON and XML, but anyway. I'm focusing on the hard problem here, which is to map repeated XML elements to JSON, if you paste the below into a Scenario you can see it work:



          * def json = 
          """
          {
          "Main": {
          "Cd":"ABC",
          "descriptionTxt":"Sample Main",
          "type":"A",
          "codeType":"P",
          "dt":"2018-10-15T00:00:00-05:00",
          "validity":"3",
          "segment":"Personal"
          },
          "testList":[
          {
          "code":"123",
          "descriptionTxt":"My Description",
          "categoryCd":"DUDU"
          },
          {
          "code":"675",
          "descriptionTxt":"His Description"
          },
          {
          "code":"345",
          "descriptionTxt":"Your Description",
          "categoryCd":"BH"
          }
          ]
          }
          """
          * def xml =
          """
          <ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
          <ns4:Test>
          <ns5:code>123</ns5:code>
          <ns5:description>My Description</ns5:description>
          <ns5:categoryCode>DUDU</ns5:categoryCode>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>345</ns5:code>
          <ns5:description>Your Description</ns5:description>
          <ns5:categoryCode>BH</ns5:categoryCode>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>675</ns5:code>
          <ns5:description>His Description</ns5:description>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          </ns4:root>
          """
          * def list = $xml/root/Test
          * def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
          * def fun = function(x){ return { code: xpath(x, '/Test/code'), descriptionTxt: xpath(x, '/Test/description'), categoryCd: xpath(x, '/Test/categoryCode') } }
          * def temp = karate.map(list, fun)
          * print temp
          * print json.testList
          * match json.testList contains temp


          Mapping the rest of the JSON is an exercise for you. Please refer to the docs. Also see this answer for more ideas: Karate - Match two dynamic responses






          share|improve this answer













          It would have been nice if you took the time to post well-formed JSON and XML, but anyway. I'm focusing on the hard problem here, which is to map repeated XML elements to JSON, if you paste the below into a Scenario you can see it work:



          * def json = 
          """
          {
          "Main": {
          "Cd":"ABC",
          "descriptionTxt":"Sample Main",
          "type":"A",
          "codeType":"P",
          "dt":"2018-10-15T00:00:00-05:00",
          "validity":"3",
          "segment":"Personal"
          },
          "testList":[
          {
          "code":"123",
          "descriptionTxt":"My Description",
          "categoryCd":"DUDU"
          },
          {
          "code":"675",
          "descriptionTxt":"His Description"
          },
          {
          "code":"345",
          "descriptionTxt":"Your Description",
          "categoryCd":"BH"
          }
          ]
          }
          """
          * def xml =
          """
          <ns4:root xmlns:ns4="http://foo.com" xmlns:ns5="http://bar.com">
          <ns4:Test>
          <ns5:code>123</ns5:code>
          <ns5:description>My Description</ns5:description>
          <ns5:categoryCode>DUDU</ns5:categoryCode>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>345</ns5:code>
          <ns5:description>Your Description</ns5:description>
          <ns5:categoryCode>BH</ns5:categoryCode>
          </ns4:Test>
          <ns4:Test>
          <ns5:code>675</ns5:code>
          <ns5:description>His Description</ns5:description>
          <ns5:unwanted>Unwanted XML Parameter</ns5:unwanted>
          </ns4:Test>
          </ns4:root>
          """
          * def list = $xml/root/Test
          * def xpath = function(x, p){ try { return karate.xmlPath(x, p) } catch (e) { return '#notpresent' } }
          * def fun = function(x){ return { code: xpath(x, '/Test/code'), descriptionTxt: xpath(x, '/Test/description'), categoryCd: xpath(x, '/Test/categoryCode') } }
          * def temp = karate.map(list, fun)
          * print temp
          * print json.testList
          * match json.testList contains temp


          Mapping the rest of the JSON is an exercise for you. Please refer to the docs. Also see this answer for more ideas: Karate - Match two dynamic responses







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 26 '18 at 4:37









          Peter ThomasPeter Thomas

          13.8k31844




          13.8k31844













          • Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

            – Nitheesh hunsur
            Nov 30 '18 at 7:34













          • @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

            – Peter Thomas
            Nov 30 '18 at 8:32



















          • Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

            – Nitheesh hunsur
            Nov 30 '18 at 7:34













          • @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

            – Peter Thomas
            Nov 30 '18 at 8:32

















          Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

          – Nitheesh hunsur
          Nov 30 '18 at 7:34







          Thanks Peter; I have one more issue during implementation. '* def fun = function(x){ return{xml path traversing goes here} }' this part of the code throws 'at ✽.* def fun = function(x){return{xml path traversing goes here} }(Test/Features/Validation.feature:24) Caused by: javax.script.ScriptException: <eval>:1:38 Expected comma but found function(x){ return { xml path traversing goes here } }' error.

          – Nitheesh hunsur
          Nov 30 '18 at 7:34















          @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

          – Peter Thomas
          Nov 30 '18 at 8:32





          @Nitheeshhunsur please mark this answer as accepted and open a new question. else it gets confusing

          – Peter Thomas
          Nov 30 '18 at 8:32


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53471153%2fhow-to-compare-xml-response-with-json-in-karate%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)