通过属性值的子字符串匹配来查找节点

XML

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

XPATH

/Galaxy/*[contains(@name,'Ear')]

要么

//*[contains(@name,'Ear')]

双引号也可用于代替单引号:

/Galaxy/*[contains(@name, "Ear")]

OUTPUT

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