Hmm.. I think I had a similar problem about partitioning a text before.
Does the structure of the text have a children elements or they're all siblings?
- <div>
- <div>Child</div>
- </div>
- <div>
- Sibling
- </div>
If they have children, I hope there's some tool to help you because the only other solution I know would be doing it all by hand using stack-like logic so that you won't mess up with the tags and their children.
Now, It they're all siblings you could only select the first one and then iterate through the siblings:
http://jsfiddle.net/jWEZ3/