Functions

example2.cpp File Reference

#include <xmlstorage.h>
#include <iostream>
Include dependency graph for example2.cpp:

Go to the source code of this file.

Functions

void test_write ()
void test_read ()
int main ()

Function Documentation

int main (  )

Definition at line 97 of file example2.cpp.

References test_read(), and test_write().

{
    test_write();
    test_read();

    return 0;
}

Here is the call graph for this function:

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';
}

Here is the call graph for this function:

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");
}

Here is the call graph for this function: