In the above xml sample I would like to select all the books that belong to class foo and not in class bar by using xpath.
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book class="foo">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book class="foo bar">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book class="foo bar">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
</bookstore>
See Question&Answers more detail:os