Xpath request for the same level tags ..?

I have an XML file -

<Books> <Book> <PubDetails> <Pub Name="ABC"/> <Year Y="1999"/> </PubDetails> <Book Subject="Computers">XPath 2.0</Book> </Book> <Book> <PubDetails> <Pub Name="ABC"/> <Year Y="1999"/> </PubDetails> <Book Subject="Management">Financial Management</Book> </Book> </Books> 

I want to get a Subject when Y is passed as a parameter.

For example: if I quit in 1999, then I should get "Computers", "Management" as a result.

What will be the XPath 1.0 query?

+4
source share
1 answer

Note that the year parameter contains a value.

 //Book[PubDetails/Year/@Y = $year]/Book/@Subject 
+5
source

Source: https://habr.com/ru/post/1384064/


All Articles