< prev index next >

src/java.xml/share/classes/javax/xml/xpath/package-info.java

Print this page




 131  * A wildcard operator, *, causes all element nodes to be selected.
 132  * The following example selects all children elements of a
 133  * <code>&lt;foo&gt;</code> element:
 134  *
 135  * <blockquote>
 136  * <pre>
 137  *     /foo/*
 138  * </pre>
 139  * </blockquote>
 140  *
 141  * <p>
 142  * In addition to element nodes, XPath location paths may also address
 143  * attribute nodes, text nodes, comment nodes, and processing instruction
 144  * nodes. The following table gives examples of location paths for each
 145  * of these node types:
 146  *
 147  * <table class="striped">
 148  *     <caption>Examples of Location Path</caption>
 149  *     <thead>
 150  *         <tr>
 151  *             <th>Location Path</th>
 152  *             <th>Description</th>
 153  *         </tr>
 154  *     </thead>
 155  *     <tbody>
 156  *         <tr>
 157  *             <td>
 158  *                 <code>/foo/bar/<strong>@id</strong></code>
 159  *             </td>
 160  *             <td>
 161  *                 Selects the attribute <code>id</code> of the <code>&lt;bar&gt;</code> element
 162  *             </td>
 163  *         </tr>
 164  *         <tr>
 165  *             <td><code>/foo/bar/<strong>text()</strong></code>
 166  *             </td>
 167  *             <td>
 168  *                 Selects the text nodes of the <code>&lt;bar&gt;</code> element. No
 169  *                 distinction is made between escaped and non-escaped character data.
 170  *             </td>
 171  *         </tr>
 172  *         <tr>
 173  *             <td><code>/foo/bar/<strong>comment()</strong></code>
 174  *             </td>
 175  *             <td>
 176  *                 Selects all comment nodes contained in the <code>&lt;bar&gt;</code> element.
 177  *             </td>
 178  *         </tr>
 179  *         <tr>
 180  *             <td><code>/foo/bar/<strong>processing-instruction()</strong></code>
 181  *             </td>
 182  *             <td>
 183  *                 Selects all processing-instruction nodes contained in the
 184  *                 <code>&lt;bar&gt;</code> element.
 185  *             </td>
 186  *         </tr>
 187  *     </tbody>
 188  * </table>
 189  *
 190  * <p>
 191  * Predicates allow for refining the nodes selected by an XPath
 192  * location path. Predicates are of the form
 193  * <code>[<em>expression</em>]</code>. The following example selects all
 194  * <code>&lt;foo&gt;</code> elements that contain an <code>include</code>
 195  * attribute with the value of <code>true</code>:
 196  *
 197  * <blockquote>
 198  * <pre>
 199  *     //foo[@include='true']
 200  * </pre>
 201  * </blockquote>




 131  * A wildcard operator, *, causes all element nodes to be selected.
 132  * The following example selects all children elements of a
 133  * <code>&lt;foo&gt;</code> element:
 134  *
 135  * <blockquote>
 136  * <pre>
 137  *     /foo/*
 138  * </pre>
 139  * </blockquote>
 140  *
 141  * <p>
 142  * In addition to element nodes, XPath location paths may also address
 143  * attribute nodes, text nodes, comment nodes, and processing instruction
 144  * nodes. The following table gives examples of location paths for each
 145  * of these node types:
 146  *
 147  * <table class="striped">
 148  *     <caption>Examples of Location Path</caption>
 149  *     <thead>
 150  *         <tr>
 151  *             <th scope="col">Location Path</th>
 152  *             <th scope="col">Description</th>
 153  *         </tr>
 154  *     </thead>
 155  *     <tbody>
 156  *         <tr>
 157  *             <th scope="row">
 158  *                 <code>/foo/bar/<strong>@id</strong></code>
 159  *             </th>
 160  *             <td>
 161  *                 Selects the attribute <code>id</code> of the <code>&lt;bar&gt;</code> element
 162  *             </td>
 163  *         </tr>
 164  *         <tr>
 165  *             <th scope="row"><code>/foo/bar/<strong>text()</strong></code>
 166  *             </th>
 167  *             <td>
 168  *                 Selects the text nodes of the <code>&lt;bar&gt;</code> element. No
 169  *                 distinction is made between escaped and non-escaped character data.
 170  *             </td>
 171  *         </tr>
 172  *         <tr>
 173  *             <th scope="row"><code>/foo/bar/<strong>comment()</strong></code>
 174  *             </th>
 175  *             <td>
 176  *                 Selects all comment nodes contained in the <code>&lt;bar&gt;</code> element.
 177  *             </td>
 178  *         </tr>
 179  *         <tr>
 180  *             <th scope="row"><code>/foo/bar/<strong>processing-instruction()</strong></code>
 181  *             </th>
 182  *             <td>
 183  *                 Selects all processing-instruction nodes contained in the
 184  *                 <code>&lt;bar&gt;</code> element.
 185  *             </td>
 186  *         </tr>
 187  *     </tbody>
 188  * </table>
 189  *
 190  * <p>
 191  * Predicates allow for refining the nodes selected by an XPath
 192  * location path. Predicates are of the form
 193  * <code>[<em>expression</em>]</code>. The following example selects all
 194  * <code>&lt;foo&gt;</code> elements that contain an <code>include</code>
 195  * attribute with the value of <code>true</code>:
 196  *
 197  * <blockquote>
 198  * <pre>
 199  *     //foo[@include='true']
 200  * </pre>
 201  * </blockquote>


< prev index next >