xpath Find nodes by substring matching of an attribute's value (case-insensitive)


Example

XML

<Galaxy>
    <name>Milky Way</name>
    <CelestialObject name="Earth" type="planet"/>
    <CelestialObject name="Sun" type="star"/>
</Galaxy>

XPATH

/Galaxy/*[contains(lower-case(@name),'ear')]

or

//*[contains(lower-case(@name),'ear')]

or, with the string in double quotes:

//*[contains(lower-case(@name), "ear")]

OUTPUT

<CelestialObject name="Earth" type="planet" />