查找具有特定属性的节点

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