通過屬性值的子字串匹配來查詢節點

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" />