views:

39

answers:

1

On an html-page I have from 0-4 divs with a specific class name.

What I want to do is get the html from the start to the first div, then from div1 position to div2 position, then div2 to div3, div3 to div4, and lastly div4 to end html.

Ive managed to do this with html.substring(0, div1.innerhtmlPos) , html.substring(div1End, div2.innerHtmlPos), etc. because I have yet to find out how to get the actual positions of the divs. I have tried StreamPosition, but if I try html.substring(0, streamposOfDiv1) it gets cut off at the wrong place.

Is there any way to get all the html over a node and between nodes?

A: 

I may be missing something here, but why not RemoveChild all the divs from the document and then get the HTML?

bobince
Pretty hard to explain. But I am taking all the html from one document and wrapping it around some elements in another document. So if I have 4 divs with class=findme, i have 5 pieces of html to append before and after each element in the other document. Im sorry, this is probably making no sense. The problem remains the same though. I need to find all html before node X, and all html between node x1 and node x2
Contra
Then ReplaceChild the old divs with the new element content? (ImportNode to get them from another document; use a DocumentFragment if the new content is multiple elements.) DOM processing is usually a much more reliable way to go than anything involving HTML string hacking.
bobince