How can I get the list of all canteenIDs (50,51,52) which belongs to companyID="1"?
I have tried with the expressions:
String expression = "/invoice/companySetup[@companyID='1']/canteen/canteenID"
This path seems just fine. Only, if you continue to use selectSingleNode() as shown in your first post, you won't possibly get them as such. You can certainly use selectNodes() (read the documentation) as a sort of natural continuity.
But
you should notice from the documentation that selectSingleNode() and selectNodes() and many others are deprecated for some time. You should look for the use of XPathExpression and Filter etc... to do it in the future. It's up to you.