The Apache Software Foundation > Apache XMLBeans

XQueryXPath Sample


Author: Steve Traut

Available: 2005-07-08

Versions: xmlbeans-v2

This sample illustrates how you can use the XMLBeans API to execute XPath and XQuery expressions. The sample illustrates these features:

  • Using the XmlObject.selectPath and XmlCursor.selectPath methods to execute XPath expressions. The selectPath method's results (if any) are always chunks of the instance queried against. In other words, changes to query results change the original instance. However, you work with results differently depending on whether selectPath was called from an XmlObject or XmlCursor instance. See the SelectPath class for more information.
  • Using the XmlObject.execQuery and XmlCursor.execQuery methods to execute XQuery expressions. Results of these queries are copied into new XML, meaning that changes to results do not change the original instance. Here again, you work with results differently depending how which method you used to query. See the ExecQuery class for more information.