I have a text html document and I would like to delete all html code and leave all the plain text.
<p>Random text generated by some method</p>
<p style="text-align:center;">centered text example</p>
<p>Full name</p>
<p>IRSP</p>
output should be:
Random text generated by some method centered text example Full name IRSP
I'm kinda of a new so any docs related to this are welcome.
You can use a DOMParser to parse the string and get the result's textContent:
const str = `<p>Random text generated by some method</p>
<p style="text-align:center;">centered text example</p>
<p>Full name</p>
<p>IRSP</p>`
const res = new DOMParser().parseFromString(str, 'text/html').body.textContent;
console.log(res)