string()
works great on a certain webpage I am trying to extract text from.
http://www.bing.com/search?q=lemons&first=111&FORM=PERE
has similar structure. For bing, the xpath I have tried is
string(//h3/a)
which works great to get the search results, even with strong tags etc, but only returns the first result. Is there something like strings(), so I can get the full text of each
//h3/a
result?
No, Not in XPath 1.0.
From the W3C XPath 1.0 Specification (the only normative document about XPath 1.0):
So, if you only have an XPath 1.0 engine available, you need to select the node-set of all
//h3/aelements and then in your programming language that is hosting XPath, to iterate on each node and get its string value separately.In XPath 2.0 use:
The result of evaluating this XPath 2.0 expression is a sequence of strings, each of which is the string value of one of the
//h3/aelements.