xpath Get the count of nodes How many plants are there in the house?


Example

XML

<House>
    <LivingRoom>
        <plant name="rose"/>
    </LivingRoom>
    <TerraceGarden>
        <plant name="passion fruit"/>
        <plant name="lily"/>
        <plant name="golden duranta"/>
    </TerraceGarden>
</House>

XPATH

count(/House//plant)

OUTPUT

4.0