I have XML file like
<Parent>
<child1 key= "">
<sub children>
</child1>
<child2 key="">
<sub children>
</child2>
</parent>
In this XML file I would like to get all nodes which have attribute 'key'. How to achieve this using best Java XML Parser? I tried with StAX parser but it has to check every element to check whether it has attribute 'key' or not. So, it takes time to give output in case of large files.