#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 132 of file example1.cpp.
References test_read(), and test_write().
{ test_write(); test_read(); return 0; }
void test_read | ( | ) |
Definition at line 94 of file example1.cpp.
References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::go(), XMLStorage::XMLPos::go_down(), XMLStorage::XMLDoc::read_file(), and TEXT.
{ XMLDoc doc; // Einlesen des XML-Files doc.read_file(TEXT("example1.xml")); XMLPos pos(&doc); string text, filename, name; // Abfrage eines Elementinhalts, beispielsweise von FONT_FILENAME if (pos.go_down("PARAMS")) { if (pos.go_down("TEXT")) { text = pos->get_content(); pos.back(); // </TEXT> } // Abfrage eines Elementinhalts, beispielsweise von FONT_FILENAME if (pos.go_down("NAME")) { name = pos->get_content(); pos.back(); } pos.back(); // </PARAMS> } // Abfrage eines Elementinhalts, beispielsweise von FONT_FILENAME if (pos.go("PARAMS/FONT/FONT_FILENAME")) { filename = pos->get_content(); pos.back(); } // Ausgabe der ermittelten Werte cout << "text: " << text << '\n'; cout << "font filename: " << filename << '\n'; cout << "name: " << name << '\n'; }
void test_write | ( | ) |
Definition at line 49 of file example1.cpp.
References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::create(), TEXT, and XMLStorage::XMLDoc::write_file().
{ XMLDoc doc; XMLPos pos(&doc); // Zusammenstellen der XML-Struktur im Dokument 'doc' pos.create("PARAMS"); pos.create("TEXT"); pos->set_content("Testgruppe und Straße"); pos.back(); // </TEXT> pos.create("COLOR"); pos.create("RED"); pos->set_content("234"); pos.back(); // </RED> pos.create("GREEN"); pos->set_content("22"); pos.back(); // </GREEN> pos.create("BLUE"); pos->set_content("33"); pos.back(); // </BLUE> pos.back(); // </COLOR> pos.create("FONT"); pos.create("FONT_FILENAME"); pos->set_content("Arial.ttf"); pos.back(); // </FONT_FILENAME> pos.create("SIZE"); pos->set_content("12"); pos.back(); // </SIZE> pos.back(); // </FONT> pos.create("NAME"); pos->set_content("Müller ÄÖÜ ß"); pos.back(); // </NAME> pos.back(); // </PARAMS> // Schreiben der XML-Datei doc.write_file(TEXT("example1.xml")); }