Xpath query for 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 retrieve the Subject when Y is passes as parameter.

For Ex: If I pass 1999, then I should get Computers, Management as output.

What will be the XPath 1.0 query?

Answers


Consider that the parameter year contains the value.

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

Need Your Help

Is using an object instantiation as an enum entry's value good practice?

java object enums instantiation

First off, apologies if this is a duplicate of an existing question. Wasn't precisely sure how to word my question so that may be why I haven't found a clear answer yet. Essentially, I want to know...

Eclipse Debug as remote Java application break points not hit

eclipse gwt tomcat remote-debugging

This is one of those problems that drives you on the verge of sanity.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.