You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by "Loberg, Sven G." <Sv...@BELLSOUTH.COM> on 2004/07/23 21:45:23 UTC

Using Xquery with XmlObjects and XmlCursor: Filtering Out Child Elements

Does XmlCursor.execQuery() support the ability to filter out specific
nested child elements to return a subset of child elements within an
XmlObject using the execQuery method. Or vice versa be able to specify a
subset of nested child elements to be returned (similar to a SQL
statement of "SELECT SuccessCode_Field, User_Field FROM
TestRequest_Table). 

For example:

An XmlObject "unfilteredDoc" with the following structure:

<TestRequest xmlns="com/ci/services/TestResponseV1">
	<SuccessCode>true</SuccessCode>
	<Message>This a test.</Message>
	<User>Test_User</User>
</TestRequest>

Desired Result:

<TestRequest xmlns="com/ci/services/TestResponseV1\">
	<SuccessCode>true</SuccessCode>
	<User>Test_User</User>
</TestRequest>

// ---- Code ----

XmlCursor empCursor = unfilteredDoc.newCursor();

XmlCursor resultCursor = empCursor.execQuery(queryExpression);

if (!(resultCursor.getTextValue().trim().equals("")))
{
       filteredDoc = resultCursor.getObject();

       // dispose of the result cursor
              resultCursor.dispose();
}

I appreciate your suggestions...

Thanks,

Sven