17.2. Addressing multiple objects A location path is capable of addressing multiple objects. For example, the expression in Example 17-1 addresses all caption elements within figure elements that are within chapter elements within book elements. Example 17-1. Location path /book/chapter/figure/caption In the book whose structure is shown in Figure 17-2, the expression in Example 17-1 would address the first two caption elements, because they are children of figure elements. It would not address the third, which is the child of an example element. Figure 17-2. Document structure Example 17-2 shows the XML representation of the book. Example 17-2. A short book in XML <?xml version="1.0"?> <book> <chapter> <par author="bd">First paragraph. <emph>Really.</emph></par> <par author="cg">Second paragraph.</par> <figure picfile="one.jpg"> <caption>The first figure's caption</caption> </figure> <par>Third paragraph.</par> <figure picfile="two.jpg"> <caption>The second figure's caption.</caption> </figure> </chapter> <chapter> <par author="pp">Chapter 2, first paragraph.</par> <example> <caption>The first example.</caption> </example> <par>Chapter 2, second paragraph.</par> <par author="bd">Chapter 2, third paragraph.</par> </chapter> </book> |