Get a string sequence from a node-set in xpath 1.0

Posted by Miguel on Stack Overflow See other posts from Stack Overflow or by Miguel
Published on 2010-05-12T14:08:44Z Indexed on 2010/05/12 17:14 UTC
Read the original article Hit count: 239

Filed under:

I'm using xpath 1.0 to parse an html file and I want to get a string sequence from a node-set. First I select a node-set (eg: //div) and then I want the string-value of each node of the set. I've tried with string(//div) but it only returns the string-value of the first node in the set.

Example
<foo>
<div>
bbbb<p>aaa</p>
</div>
<div>
cccc<p>aaa</p>
</div>
</foo>

I expect a result like ('bbbbaaa', 'ccccaaa') but I only get 'bbbaaa'

© Stack Overflow or respective owner

Related posts about xpath