To use the DOMParser with Node.js, we use the xmldom package.
For instance, we write
const DOMParser = require("xmldom").DOMParser;
const parser = new DOMParser();
const document = parser.parseFromString("Your XML String", "text/xml");
to import DOMParser with require.
And then we create a DOMParser object.
We then call parseFromString to parse the XML string.