xpath Find nodes that have a specific attribute Find nodes by substring matching the start of an attribute's value


Example

XML

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

XPATH

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

or

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

OUTPUT

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