Naman
Naman

Reputation: 1041

Using Mozilla firefox parser (Rendering Engine) in an extension

I want to build a Firefox extension which will use Firefox parser(Rendering Engine). I want to feed some HTML data to parser and in return, it will give me HTML and java-script content separately. Then I will do some processing on it. Is there any API or another way to do it?

Upvotes: 1

Views: 405

Answers (1)

M.J. Saedy
M.J. Saedy

Reputation: 346

you mean something like this...

let s = "<i>cool</i><script>alert('cool!')</script>";
var parser = new DOMParser();
let doc = parser.parseFromString(s, "text/html");

//do whatever you want....
doc.body.appendChild(doc.createElement('hr'));
alert(doc.documentElement.outerHTML)

Upvotes: 2

Related Questions