quickstart_01.cpp

A first program to output some data in an xml stream.

In this first example, we could see how to put a start tag into the stream. We only need to use xml::stag("tag_name"). To close the tag, we use the xml::etag(). We do not need to put the end tag name, ximol automagically put it into the stream.

#include <iostream>
#include <ximol/ximol.hpp>

using namespace std;
using namespace ximol;

int main()
{
    xostringstream xos;
    double x=2.345;
    int y=23875645;

    // write the xml prolog
    xos << xml::prolog();

    xos << xml::stag("MyFirstTag");

    // let put an double
    xos << xml::content(x);
    
    // let put an int into a tag
    xos << xml::stag("MyInt") << xml::content(y) << xml::etag();

    // an other way toid do this
    xos << xml::box("MyInt",xml::content(y));

    xos << xml::etag();

    // ouput on the stdout
    cout << str<string>::cast(xos.str()) << endl;
    return 0;
};


Donate to the XiMoL project SourceForge.net Logo If you have any questions about XiMoL, you could write to tournois@users.sourceforge.net.