XML
Introduction
XML is important in many areas, including information storage and retrieval, publishing, and network communication; in this chapter, you'll learn to work with XML in C++. Because this book is about C++ rather than XML, I'll assume you already have some experience with the various XML-related technologies I discuss, including SAX, DOM, XML Schema, XPath, and XSLT. Don't worry if you're not an expert in all of these areas; the recipes in this chapter are more or less independent of each other, so you should be able to skip some of the recipes and still understand the rest. In any case, each recipe provides a quick explanation of the XML concepts and tools it uses.
If you come from another programming language, such as Java, you may expect to find the tools for XML processing in C++ to be included in the C++ standard library. Unfortunately, XML was in its infancy when the C++ standard was approved, and while there's strong interest in adding XML processing to a future version of the C++ standard library, for now you will have to rely on the collection of excellent third-party XML libraries available in C++.
Before you start reading recipes, you may want download and install the libraries I'll be covering in this chapter. Table 14-1 shows the homepage of each library; Table 14-2 shows the features of each library and the recipes that use the library. The table doesn't show each library's exact level of conformance to the various XML specifications and recommendations because this information is likely to change in the near future.
Library name |
Homepage |
---|---|
TinyXml |
www.grinninglizard.com/tinyxml |
Xerxes |
xml.apache.org/xerces-c |
Xalan |
xml.apache.org/xalan-c |
Pathan 1 |
software.decisionsoft.com/pathanIntro.html |
Boost.Serialization |
www.boost.org/libs/serialization |
Library name |
Features |
Recipes |
---|---|---|
TinyXml |
DOM (nonstandard) |
Recipe 14.1 |
Xerxes |
SAX2, DOM, XML Schema |
Recipe 14.2-Recipe 14.8 |
Xalan |
XSLT, XPath |
Recipe 14.7-Recipe 14.8 |
Pathan |
XPath |
Recipe 14.8 |
Boost.Serialization |
XML Serialization |
Recipe 14.9 |