get pieces of text from unpaired tags

get pieces of text from unpaired tags


Hi,

I'm trying to get the text nodes of this paragraph:

I would like to get each part of text: text0, text1, text2,text3 and text4, and surround it with a div element.

I've tried to get the paragraph childnodes into a list of nodes, but it doesn't get the textnodes.

Do you know a way to get these pieces of text and surround them?




  1. <p><span>text0<span> text1</span>text2<span >text3</span>text4</span></p>
Regards