I have a string representing a stand-alone (and valid XHTML 1.0 Strict) HTML document, something like
var html = "<?xml ... <!DOCTYPE ... <html><head><style>...</style></head>
<body><table>...</table></body></html>";
The body of this HTML document contains a table whose CSS-style
is described in the head of the HTML document.
I also have a DOM-tree of another HTML document.
How can I include into this DOM-tree the DOM-tree of the table with the correct style (as described in the HTML-string)?
I am especially interested in a jQuery-based solution.
EDIT: To be more concrete, an example of an HTML-string that I’m talking about
is embedded into this XML-document.
I may be waaaay missing the point, but why not load the string into an IFRAME to render – this solves all the problems of having two separate DOM trees, and two separate sets of CSS rules, to me.
This code will do it:
(which I lifted from here: putting html inside an iframe (using javascript))
Then if you are concerned about the size of the IFRAME, you can set it with: