Is it possible to use the DOMParser API when building a vscode exstension?

151 Views Asked by At

Hey i'm trying to use the DOMParser api inside a vscode extension that i'm making right now. vscode tells me it cant find the DOMParser instance and relevant methods when i try to use it. I managed to use a library to achieve parsing html.

I'm curious why the DOMParser api cant be used in the environment. Is it because it's not ran in an environment like the browser?

thanks.

1

There are 1 best solutions below

1
alefragnani On

VS Code extensions are primarily built using Node.js, and it seems DOMParser is not available in Node.js. So, you should depend on some library.

In this post (https://stackoverflow.com/a/55668667/7758872) there is a lot of libraries for your to try out.

Hope this helps