Write an XML content
Table of Contents
The first thing to do when reading or writing a XML file/stream, is to declare the Document interface
Include exml
#include <exml/exml.hpp>
Declare document interface
exml::Document doc;
Write an XML file
Write an xml tree is done like:
Write an XML Stream
Writing a stream is done like this:
std::string streamOut;
bool retGenerate = doc.generate(streamOut);
Operation on Tree
Add Node/Declaration:
Add an Node/Element:
Remove a Node/Element:
Add an attribute (simple version):
Add an attribute (complex version):
Remove an attribute:
Object concept
the exml concept is to abstract the implementation of the internal system. All the element are maped on shared memory. Then if you asign an element to an other, it is the same. You need to clone it if you want to have new standalone element.
All example file
#include <test-debug/debug.hpp>
#include <exml/exml.hpp>
#include "write.hpp"
static void writeToFile() {
exml::Document doc;
TEST_INFO("store");
TEST_INFO("parse ret = " << retGenerate);
TEST_INFO("Debug display of the tree:");
doc.display();
}
static void writeToString() {
exml::Document doc;
TEST_INFO("generate");
std::string streamOut;
bool retGenerate = doc.generate(streamOut);
TEST_INFO("parse ret = " << retGenerate);
TEST_INFO("Debug display of the tree:");
doc.display();
}
static void writeAll() {
exml::Document doc;
doc.display();
// remove all node with this name
}
void appl::write() {
writeToFile();
writeToString();
writeAll();
}