# XQueryUtil.java Sample

This topic inludes the source code for the XQueryUtil.java Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/ControlDevKit/ControlFeatures/jcxCreate/

## Sample Source Code

`01 package jcxCreate; 02 03 import com.bea.xml.XmlCursor; 04 import java.lang.reflect.InvocationTargetException; 05 import com.bea.xml.XmlObject; 06 07 /* 08 * Represents XQuery functionality to the XQuery control. 09 */ 10 public class XQueryUtil 11 { 12 /* 13 * Returns an XMLBeans XmlCursor object containing the results of 14 * the query. If results are not possible, perhaps because the expression 15 * was incorrect, the method throws an exception. 16 */ 17 public XmlCursor runXQueryExpression(XmlObject xml, String expression) 18 throws InvocationTargetException, Exception 19 { 20 XmlCursor queryResults = null; 21 try{ 22 XmlCursor itemCursor = xml.newCursor().execQuery(expression); 23 queryResults = itemCursor; 24 } catch (Exception e){ 25 throw e; 26 } 27 return queryResults; 28 } 29 }`