1

I have the following XPath

//*[@href="/slug1/30/slug2/slug3/slug4" and normalize-space(text())="Push"]

The 30 is dynamic and changes so need this wildcard

E.g

//*[@href="/dashboard/*/zones/vod/push" and normalize-space(text())="Push"]

but this does not seem to work.

Any ideas how to get wildcard for this XPath?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Guru Surfer
  • 111
  • 8

2 Answers2

1

If you want to match any element in an XPath itself, * would be fine, but you're looking to match any substring in text. In XPath 1.0, you can use starts-with() and the XPath 1.0 equivalent of ends-with().

Since you can use XPath 2.0, use matches() to match a regex.

For one or more characters in the wildcard position, use .+:

//*[matches(@href,"/slug1/.+/slug2/slug3/slug4") and normalize-space(text())="Push"]

For digits only there, use \d+, etc.

kjhughes
  • 106,133
  • 27
  • 181
  • 240
0

Not sure which programming language you are using, I believe it is xslt.

As per my understanding you can use wild cards for input tags but not for values of the tags.

I would suggest to use contains functionality in xslt by slipting the value to use using string functionality and validate

gautham
  • 87
  • 2
  • 12