查詢具有特定屬性值的節點

XML

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

XPATH

/Galaxy/*[@name='Sun']

要麼

//*[@name='Sun']

OUTPUT

<CelestialObject name="Sun" type="star" />