Jesse
Jesse

Reputation: 69

Retrieve part of text

I have following XPath to retrieve the sentence:

{//node/node/node/node[@class='InfoType18']/metalist/meta[@name='custom.ECO.regul1'],' (')}

Result is then:

This is a test (EU) 206/2012

I work with a dropdown menu, so the total characters of text will change. There are 2 parts: 1) The part before (EU) 206/2012 2) The part (EU) 206/2012

Problem 1: I already solved: to retrieve the text before the (EU) code:

{substring-before(//node/node/node/node[@class='InfoType18']/metalist/meta[@name='custom.ECO.regul1'],' (')}

Problem 2: I don't find a manner because I can't say: substring-before the (EU) because text length is variable.

How can I fix this issue?

Upvotes: 0

Views: 28

Answers (1)

Ayoub_B
Ayoub_B

Reputation: 700

Have you tried substring-after it works the same way as substring-before.

So the xPath to retrieve the part after (EU) is the following:

substring-after(//node/node/node/node[@class='InfoType18']/metalist/meta[@name='custom.ECO.regul1'],')')

And the text's length shouldn't matter in this case.

Upvotes: 1

Related Questions