An example of creating an XML document

    // Create the document, and the top level <windows> element.
    auto doc=x::xml::doc::create();

    auto lock=doc->writelock();

    auto windows=lock->create_child()->element({"windows"});

    for (const auto &coords:coordinates)
        // Position the lock. At the end of the iteration of this loop,
        // the lock's position remains on the last created XML element, and
        // this is the simplest way to bring it back on the top level
        // <windows> element.


        // Create a child factory. Use it to create the new <window>
        // element, then it's <name> child, then it's child text element.

        auto window=lock->create_child()->element({"window"});

        std::ostringstream x, y, width, height;

        x << coords.second.x;
        y << coords.second.y;
        width << coords.second.width;
        height << coords.second.height;

        // At this point the creator is pointing to the text child element
        // of the <name> element. Move the creator back to the
        // <name> using parent(), use create_next_sibling() to construct
        // a factory that creates the next sibling element, then create the
        // <x> element, then its text child.

        // In the same manner create the remaining elements.


This example creates an XML file that looks like this:

<?xml version="1.0"?>

In this example, coordinates is a map containing a std::string for a key, and a value with x, y, width and height members. This data gets written out into a simple, basic, XML file.