SourceForge.net Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Examples

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 Fri Sep 25 06:55:26 2009 for XQilla Simple API by  doxygen 1.3.9.1