SourceForge.net Logo

simple-basic.cpp

This example executes a simple XQuery expression ("1 to 100"), which returns the numbers from 1 to 100 inclusive.

#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;
}

Generated on Mon Mar 1 21:15:51 2010 for XQilla Simple API by  doxygen 1.6.1