user1175197
user1175197

Reputation: 379

XPATH Expression help needed

I have an XML file:

<?xml version="1.0" encoding="UTF-8"?>
<root>
   <nodeA>
   </nodeA>
   <nodeB>
       <nodeB></nodeB>
       <nodeB></nodeB>
       <nodeB></nodeB>
       <nodeB></nodeB>
   </nodeB>

   <nodeC>
   </nodeC>
</root>

I want to write an XPATH expression which will select the <nodeB> which is the parent of the other <nodeB> nodes. I tried something like

"//nodeB/nodeB/parent::nodeB"

but it also choses <nodeC> besides the one I want.

Can you please help?

thanks mc

Upvotes: 0

Views: 61

Answers (1)

jlew
jlew

Reputation: 10591

Try this (nodeB having a child of nodeB)

//nodeB[nodeB]

Upvotes: 1

Related Questions