views:

69

answers:

0

So, I have received a string of HTML from the server using Javascript. It should be relatively well formed, but each node does not necessarily have a common ancestor. Ex. Response:

<li>Item 1</li>
<li>Item 2</li>
...

The purpose here is to replace HTML currently on the page with the HTML received from the server without requiring an id or anything.

In order to meet that goal, I have generated DOM Ranges for each section of HTML to be replaced, and a means to identify those DOM Ranges.

What would be the best approach to swap HTML from within a DOM Range object?