Simple API: Basic Query
This example executes a simple XQuery expression ("1 to 100"), which returns the numbers from 1 to 100 inclusive. An
equivalent example exists for the DOM 3 API.
#include <iostream>
#include <xqilla/xqilla-simple.hpp>
int main(int argc, char *argv[]) {
// Initialise Xerces-C and XQilla by creating the factory object
XQilla xqilla;
// Parse an XQuery expression
// (AutoDelete deletes the object at the end of the scope)
AutoDelete<XQQuery> query(xqilla.parse(X("1 to 100")));
// Create a context object
AutoDelete<DynamicContext> context(query->createDynamicContext());
// Execute the query, using the context
Result result = query->execute(context);
// Iterate over the results, printing them
Item::Ptr item;
while(item = result->next(context)) {
std::cout << UTF8(item->asString(context)) << std::endl;
}
return 0;
}
CategorySimpleAPI
There are no comments on this page. [Add comment]