查詢具有特定屬性的節點

XML

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

XPATH

/Galaxy/*[@name]

要麼

//*[@name]

OUTPUT

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