Obtaining All Elements of a Particular Name from a

Although sometimes you might want all like-named elements wherever they are in a document, other times you might want only those like-named elements from a particular part of the document (branch of the tree).

For example, you might want all price elements contained in book elements, but not price elements contained in magazine elements. The query is to return such a result is:

/bookstore/book//price
               

            

This query returns all price elements that are contained in book elements. Some of these price elements are immediate children of book elements. One returned price element is a great-grandchild of the second book element. The following figure shows how the XPath processor interprets this query:

 
Free Stylus Studio XML Training: