77
rated 0 times
[
84]
[
7]
/ answers: 1 / hits: 20830
/ 13 Years ago, fri, november 4, 2011, 12:00:00
I have this string that represents the body of a page, which I would like to parse for some elements. I believe (feel free to contradict me) the best way to do so is to create an empty document, then add the body and use standard JS methods to get what I want.
But I don't seem to be able to add the body to the document. In chrome, the following code fails on line 2 with NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7
.
var dom = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
dom.firstChild.innerHTML = <body><p>Hello world</p></body>;
Is there any way to achieve what I want?
More From » dom