Trying to use the DOMParser with node js

前端 未结 7 1447
忘了有多久
忘了有多久 2020-12-01 10:17

I am running into issues when trying to use the DOMParser in my js code. In my code, I retrieve an xml file via xmlhttp.responseText soap response. I want to be able to ac

7条回答
  •  难免孤独
    2020-12-01 10:35

    I used jsdom because it's got a ton of usage and is written by a prominent web hero - no promises that it's behavior perfectly matches your browser (or even that every browser's behavior is the same) but it worked for me:

    const jsdom = require("jsdom")
    const { JSDOM } = jsdom
    global.DOMParser = new JSDOM().window.DOMParser
    

提交回复
热议问题