TheOptimizer
TheOptimizer

Reputation: 37

How to combine two XPath expressions?

I have two XPath expressions that I need to combine.

(//div[@class="filtername"])

This returns "New York Hotels" for example.

(//div[@class="filternumber"])

This returns “100” for example.

So when combining the two expressions I want the result to look like this: "New York Hotels 100"

How do I achieve this?

I think I need to use the concat function but I don’t know how to use it.

Thanks so much in advance.

Upvotes: 0

Views: 1253

Answers (1)

zx485
zx485

Reputation: 29022

If both XPath-1.0 expression each yield only one result, you can use the following fn:concat expression:

concat(//div[@class="filtername"], ' ', //div[@class="filternumber"])

This should return "New York Hotels 100".
(But without an XML file, this cannot be verified by us).

Upvotes: 2

Related Questions