CS 242 Fall 2010 : Xerces Tutorial

This page last changed on Sep 21, 2008 by csvenss2.

Xerces Tutorial

Xerces can be kind of tricky to install. The Xerces website is the best place to get information regarding compilation, building and issues. Below is my experience installing/using xerces.

Installing Xerces

All you need to do to install Xerces is download the binaries for your platform. The download page is here: http://xerces.apache.org/xerces-c/download.cgi . Pick the binary distribution that corresponds to your platform.

This should be sufficient. If your platform is not supported, you may have to compile from source. Doing so is outlined here: http://xerces.apache.org/xerces-c/build-winunix.html . Though, this should not be necessary.

Including Xerces in Your Project

In order to use Xerces, you have to specify some compiler options so that the compiler knows where to find the Xerces include files, and furthermore, where it can find the libraries. Let <xerces-path> be the path to where you extracted the Xerces download. You should use the following options when compiling:

  • -L<xerces-path>/lib/
  • -I<xerces-path>/include/
  • -lxerces-c

Note that the second options is a capital letter i, and the third option is a lowercase L. If you were using g++ it would look something like this:

g++ app.cpp -L<xerces-path>/lib/ -I<xerces-path>/include/ -lxerces-c

Using Xerces

Xerces can be fairly complex. To illustrate how it can be used, I wrote a sample parsing program:

XercesTest.cpp

XercesTest.cpp (application/octet-stream)
Document generated by Confluence on Feb 22, 2012 18:13

  1. No comments yet.

  1. No trackbacks yet.