Soap Response parsing using cypress

You can use a DOMParser to make a queryable document,


it('parses XML price', () => {
  
  const xmlStr = `<?xml version="1.0" encoding="UTF-8"?>
  <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope/" soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
     <soap:Body>
        <m:GetPriceResponse xmlns:m="https://www.w3schools.com/prices">
           <m:Price>1.90</m:Price>
        </m:GetPriceResponse>
     </soap:Body>
  </soap:Envelope>`

  const parser = new DOMParser();
  const doc = parser.parseFromString(xmlStr, "application/xml");
  const price = +doc.querySelector("Price").textContent  // numeric value of text content

  cy.wrap(price)                   
    .as('price')                   // save for later
    .should('eq', 1.90)            // verify the value
});