Have such XML:
<td>
text1
<br/>
text2
<br/>
text3
<br/>
text4
<br/>
</td>
Want to select text1 text2 text3 text4
with spaces or CRLF between them.
If I select string(/td)
it selects text1text2text3text4
. If I select string(/td/text())
it selects only text1
.
How to select all text but with spaces in-between?
You cannot select string(node-set)
, because string()
will convert the first node from its argument to string only.
Hence you get '\n text1'
from string(td/text())
.
Just use td/text()
and you will get five (!) not four text nodes.