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 #include <xmlstorage.h>
00040 using namespace XMLStorage;
00041
00042 #include <iostream>
00043 using namespace std;
00044
00045
00046 void test_write()
00047 {
00048 XMLWriter out("example-xpath.xml");
00049
00050 out.create("Test");
00051 out.create("Child");
00052 out.set_content("Wert1");
00053 out.back();
00054
00055 out.create("Child");
00056 out["id"] = XMLInt(1234);
00057 out["txt"] = "abc";
00058 out.set_content("Wert2");
00059 out.back();
00060
00061 out.create("Child");
00062 out.set_content("Wert3");
00063 out.back();
00064 out.back();
00065 }
00066
00067
00068 void test_read()
00069 {
00070 XMLDoc doc;
00071
00072
00073 doc.read_file("example-xpath.xml");
00074
00075 XMLPos pos(&doc);
00076
00077 cout << "matching 'Test/Child': " << pos.count("Test/Child") << endl;
00078 cout << "matching 'Test/Child[@id=\"1234\"]': " << pos.count("Test/Child[@id=\"1234\"]") << endl;
00079
00080 XMLDoc target_doc;
00081 pos.filter("Test/Child[@id=\"1234\" and @txt=\"abc\"]", target_doc);
00082 target_doc.write(cout);
00083
00084 pos.go("Test/Child[ 3 ]");
00085 cout << "content: " << pos->get_content() << endl;
00086 }
00087
00088
00089 int main()
00090 {
00091 test_write();
00092 test_read();
00093
00094 return 0;
00095 }