Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include <xmlstorage.h>
00043 using namespace XMLStorage;
00044
00045 #include <iostream>
00046 using namespace std;
00047
00048
00049 void test_write()
00050 {
00051 XMLDoc doc;
00052 XMLPos pos(&doc);
00053
00054
00055 pos.create("PARAMS");
00056 pos.create("TEXT");
00057 pos->set_content("Testgruppe und Straße");
00058 pos.back();
00059
00060 pos.create("COLOR");
00061 pos.create("RED");
00062 pos->set_content("234");
00063 pos.back();
00064
00065 pos.create("GREEN");
00066 pos->set_content("22");
00067 pos.back();
00068
00069 pos.create("BLUE");
00070 pos->set_content("33");
00071 pos.back();
00072 pos.back();
00073
00074 pos.create("FONT");
00075 pos.create("FONT_FILENAME");
00076 pos->set_content("Arial.ttf");
00077 pos.back();
00078
00079 pos.create("SIZE");
00080 pos->set_content("12");
00081 pos.back();
00082 pos.back();
00083
00084 pos.create("NAME");
00085 pos->set_content("Müller ÄÖÜ ß");
00086 pos.back();
00087 pos.back();
00088
00089
00090 doc.write_file(TEXT("example1.xml"));
00091 }
00092
00093
00094 void test_read()
00095 {
00096 XMLDoc doc;
00097
00098
00099 doc.read_file(TEXT("example1.xml"));
00100
00101 XMLPos pos(&doc);
00102 string text, filename, name;
00103
00104
00105 if (pos.go_down("PARAMS")) {
00106 if (pos.go_down("TEXT")) {
00107 text = pos->get_content();
00108 pos.back();
00109 }
00110
00111
00112 if (pos.go_down("NAME")) {
00113 name = pos->get_content();
00114 pos.back();
00115 }
00116 pos.back();
00117 }
00118
00119
00120 if (pos.go("PARAMS/FONT/FONT_FILENAME")) {
00121 filename = pos->get_content();
00122 pos.back();
00123 }
00124
00125
00126 cout << "text: " << text << '\n';
00127 cout << "font filename: " << filename << '\n';
00128 cout << "name: " << name << '\n';
00129 }
00130
00131
00132 int main()
00133 {
00134 test_write();
00135 test_read();
00136
00137 return 0;
00138 }