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?
Asked
Active
Viewed 376 times
1 Answers
2
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)

M.J. Saedy
- 316
- 4
- 9
-
Can you explain what you are doing here? – Naman Apr 22 '14 at 11:38
-
I'm doing what I thought you wanted, parse HTML source into a DOM document that you can manipulate using standard DOM Methods. – M.J. Saedy Apr 22 '14 at 14:44
-
Wow this is so cool! I didn't know you could do this! How to use this from XPCOM? – Noitidart Nov 15 '14 at 06:34