NoFussXML is a small, minimalist and (I hope) easy to use C++ XML parser and generator. It does not support any schemas such as DTD at present.
You can download the implementation here (v1.0.13) (Changelog).
Here is an example of usage:
int main()
{
/* define our XML object */
lib::xml data;
/* parse XML input */
std::ifstream input("input.xml");
data.read(input);
/* append some XML elements */
lib::xml::element& newItem = data.append(data.root(), "identity");
data.append(newItem, "nick").attributes().push_back(std::make_pair(std::string("value"),
std::string("MrFlibble")));
data.append(newItem, "name").attributes().push_back(std::make_pair(std::string("value"),
std::string("Mr Flibble (very cross)")));
data.append(newItem, "email").attributes().push_back(std::make_pair(std::string("value"),
std::string("flibble@starbug.net")));
data.append(newItem, "invisible").attributes().push_back(std::make_pair(std::string("value"),
std::string("1")));
/* insert an XML element at the start */
data.insert(data.root(), data.root().children().begin(), "xyzzy");
/* remove an existing XML element */
data.erase(data.root(), data.find(data.root(), "default"));
/* generate XML output */
data.write(std::cout);
return 0;
}
When given the input file input.xml the above program produces the following output:
<identities>
<xyzzy/>
<identity>
<nick value="Leigh" />
<name value="Leigh Johnston" />
<email value="leigh@i42.co.uk" />
<invisible value="0" />
</identity>
<identity>
<nick value="MrFlibble" />
<name value="Mr Flibble (very cross)" />
<email value="flibble@starbug.net" />
<invisible value="1" />
</identity>
</identities>