xmlwrapp Lightweight C++ XML parsing library

Preparing To Use xmlwrapp

Before you use xmlwrapp there are a few things you will need to know. This chapter will give you all the background you need to understand the rest of this book.

# Header Files

When you install xmlwrapp, a set of header files will be installed in the include directory of your choosing. If you don't pick a location for these file to go, they will be installed in /usr/local/include by default. All of the xmlwrapp header files will be placed into a `xmlwrapp` subdirectory.

If you are using the `pkg-config` script, you don't have to worry about where the xmlwrapp header files were installed. `"pkg-config xmlwrapp"` will add the appropriate directory to the compiler's search path.

When using the xmlwrapp header files, you can either include each file you need or use the master include file to include all xmlwrapp header files. The choice is yours and mainly depends on your style and the project you are working on.

## Using DLLs under Microsoft Windows systems

If xmlwrapp was built as a DLL, you must predefine `XMLWRAPP_USE_DLL` before including any of the library headers, e.g. typically in the project build options. Similarly, `XSLTWRAPP_USE_DLL` must be defined when using xsltwrapp as a DLL.

Note that this it is not necessary to do this when using GNU toolset, as GNU linker can automatically import symbols from the DLLs as needed. However this is required when using other toolsets, such as Microsoft C++ one, and may be slightly more efficient than relying on auto-linking even with GNU linker.

## Include xmlwrapp Header Files

#include <xmlwrapp/node.h>
#include <xmlwrapp/document.h>

## Include All xmlwrapp Header Files

#include <xmlwrapp/xmlwrapp.h>

# The xmlwrapp Namespace

To prevent pollution of the global namespace, xmlwrapp places all classes and functions in the xml namespace. For clarity, this document will always use the xml namespace prefix when showing examples.

It is your choice if you want to use the xml namespace in your code, or use one of the many forms of the "using namespace" statement.

# Initializing the XML Parser

Starting with xmlwrapp version 0.6.0, you don't have to explicitly initialize the library, it is automatically initialized at startup time, in a thread-safe way.

You may want to configure the libxml2 parser to behave differently from its default behavior. The xml::init class exists for this purpose and provides several static methods for configuring various aspects of libxml2. If you decide to tweak the defaults, it is generally good idea to do it before first use of xmlwrapp, as setting the defaults is not thread-safe and has global effect.

int main() {
xml::init::remove_whitespace(true);
...
return 0;
}
document.h
node.h
xml::init::remove_whitespace
static bool remove_whitespace(bool flag)
This member function controls whether or not the XML parser should remove ignorable whitespace around...