title: How to compare XML response with Json in Karate
body: <p>I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both. </p>
  
  <p>Note that Json response parameters are is not in-order with XML response.</p>
  
  <p><strong>JSON RESPONSE</strong></p>
  
  <pre><code>"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"
      }
  ]
  </code></pre>
  
  <p><strong>XML RESPONSE</strong></p>
  
  <pre><code>&lt;S:Body&gt;
  &lt;ns4:code&gt;ABC &lt;/ns4:code&gt;
      &lt;ns5:description&gt;Sample Main&lt;/ns5:description&gt;
      &lt;ns5:Date&gt;2018-10-15&lt;/ns5:Date&gt;
      &lt;ns5:Type&gt;A&lt;/ns5:Type&gt;
      &lt;ns5:codeType&gt;P&lt;/ns5:codeType&gt;
      &lt;ns5:validity&gt;3&lt;/ns5:validity &gt;
      &lt;ns5:Segment&gt;PERSONAL  &lt;/ns5:Segment&gt;
      &lt;ns5:unwanted&gt;Unwanted XML Parameter&lt;/ns5:unwanted&gt;
  
      &lt;ns4:Test&gt;
        &lt;ns5:code&gt;123   &lt;/ns5:code&gt;
        &lt;ns5:description&gt;My Description&lt;/ns5:description&gt;
        &lt;ns5:categoryCode&gt;DUDU&lt;/ns5:categoryCode&gt;
        &lt;ns5:unwanted&gt;Unwanted XML Parameter&lt;/ns5:unwanted&gt;
      &lt;/ns4:Test&gt;
  
      &lt;ns4:Test&gt;
        &lt;ns5:code&gt;345   &lt;/ns5:code&gt;
        &lt;ns5:description&gt;Your Description&lt;/ns5:description&gt;
        &lt;ns5:categoryCode&gt;BH&lt;/ns5:categoryCode&gt;
      &lt;/ns4:Test&gt;
  
      &lt;ns4:Test&gt;
        &lt;ns5:code&gt;675  &lt;/ns5:code&gt;
        &lt;ns5:description&gt;His Description&lt;/ns5:description&gt;
        &lt;ns5:unwanted&gt;Unwanted XML Parameter&lt;/ns5:unwanted&gt;
      &lt;/ns4:Test&gt;
  </code></pre>
  
  <p></p>