1

My response data is having text   in it.

I am not able to get data from any of the fields using xpath from this response. Karate shows "xml parsing failed, response data type set to string: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 716; The entity "nbsp" was referenced, but not declared." all xpaths (Eg: response/transaction/values/data/@name)

I need to verify the commentDisplay tag in below xml. How to proceed?/ Is there any way to remove   before fetching the value using xpath?

     <Response>
       <RequestID>1234</RequestID>
       <transaction>
          <values>
             <data name="firstName">Sumith</data>
             <data name="lastName">Menon</data>
          </values>
          <commentDisplay>
          <top>Please&nbsp;Verify&nbsp;IDCard</top>
          <bottom/></commentDisplay>
       </transaction>
 </Response>
Sumith
  • 123
  • 8

1 Answers1

1

&nbsp; is invalid in XML, refer: https://stackoverflow.com/a/36097922/143475

But you can correct this in one step:

* xml response = response.replaceAll('&nbsp;', ' ')
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248