#include <xmlstorage.h>#include <iostream>
Go to the source code of this file.
Functions | |
| void | test_write () |
| void | test_read () |
| int | main () |
| int main | ( | ) |
Definition at line 97 of file example2.cpp.
References test_read(), and test_write().
{
test_write();
test_read();
return 0;
}

| void test_read | ( | ) |
Definition at line 76 of file example2.cpp.
References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::go(), and XMLStorage::XMLDoc::read_file().
{
XMLDoc doc;
// Einlesen des XML-Files
doc.read_file("example2.xml");
XMLPos pos(&doc);
string filename;
// Abfrage eines Attributwerts, beispielsweise von "font_filename"
if (pos.go("PARAMS/FONT")) {
filename = pos["font_filename"];
pos.back();
}
// Ausgabe des ermittelten Werts
cout << "font filename: " << filename << '\n';
}

| void test_write | ( | ) |
Definition at line 49 of file example2.cpp.
References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::create(), and XMLStorage::XMLDoc::write_file().
{
XMLDoc doc;
XMLPos pos(&doc);
// Zusammenstellen der XML-Struktur im Dokument 'doc'
pos.create("PARAMS");
pos["text"] = "Testgruppe";
pos.create("COLOR");
pos["red"] = XMLInt(234);
pos["green"] = XMLInt(22);
pos["blue"] = XMLInt(33);
pos.back(); // </COLOR>
pos.create("FONT");
pos["font_filename"] = "Arial.ttf";
pos["size"] = XMLInt(12);
pos.back(); // </SIZE>
pos.back(); // </FONT>
pos.back(); // </PARAMS>
// Schreiben der XML-Datei
doc.write_file("example2.xml");
}

1.7.2