Nam G VU
Nam G VU

Reputation: 35384

How to use regular expression when choosing an XML node by XPath?

I need to search for XML nodes whose names look like "image*", i.e. start with 'image'. My sample XML:

<a name="image.1">
  <b name="image.22" />
</a>

My XPath is /b[@name='image.22']. I want to write the seletion [@name='image.22'] in the form of using regular expression there. I've tried [@name='image.+'] but it doesn't work.

Please help.

Upvotes: 1

Views: 237

Answers (1)

Dewfy
Dewfy

Reputation: 23624

Use starts-with:

[starts-with(@name, 'image.')

Upvotes: 6

Related Questions