hudi
hudi

Reputation: 16525

How to get element by attribute name which ends with defined word

In my XML I have elements

<driverConfig name="ADriver">
    ...
            </driverConfig>

            <driverConfig name="BDriver">
    ...
            </driverConfig>

Is there a way how to select all value of sub-element. Problem is I can modify just first name in this expression which I already tried but with no success:

//driverConfig[@name="*Driver"]/fd:properties/fd:property[@name="path"]

Upvotes: 0

Views: 81

Answers (1)

Martin Honnen
Martin Honnen

Reputation: 167446

With XPath 2.0 you can do //driverConfig[ends-with(@name, 'Driver')]/fd:properties/fd:property[@name="path"] respectively //driverConfig[matches(@name, 'Driver$')]/fd:properties/fd:property[@name="path"].

With XPath 1.0 you can use //driverConfig[substring(@name, string-length(@name) - 5) = 'Driver']/fd:properties/fd:property[@name="path"].

Upvotes: 1

Related Questions