Public Member Functions | Static Private Member Functions

Example1 Class Reference

Example for writing and reading a XML file. More...

List of all members.

Public Member Functions

void testWrite ()
 Write exampe XML file.
void testRead ()
 Read the example file back again.

Static Private Member Functions

static void Main (string[] args)
 Main function of Example1.

Detailed Description

Example for writing and reading a XML file.

Author:
martin

Definition at line 47 of file Example1.cs.


Member Function Documentation

static void Example1::Main ( string[]  args ) [inline, static, private]

Main function of Example1.

Parameters:
argsunused command line arguments

Definition at line 134 of file Example1.cs.

References testRead(), and testWrite().

    {
        Example1 me = new Example1();

        try {
            me.testWrite();
            me.testRead();
        } catch(Exception e) {
            System.Console.Error.WriteLine(e);
            System.Console.Error.WriteLine(e.StackTrace);
        }
    }

Here is the call graph for this function:

void Example1::testRead (  ) [inline]

Read the example file back again.

Definition at line 96 of file Example1.cs.

References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::getContent(), XMLStorage::XMLPos::go(), XMLStorage::XMLPos::goDown(), and XMLStorage::XMLDoc::readFile().

Referenced by Main().

    {
        XMLDoc doc = new XMLDoc();

         // Einlesen des XML-Files
        doc.readFile("example1.xml");

        string txt = "";
        string filename = "";

        XMLPos pos = new XMLPos(doc);

        if (pos.goDown("PARAMS")) {
            if (pos.goDown("TEXT")) {
                txt = pos.getContent();
                pos.back();
            }
            pos.back();
        }

         // Abfrage eines Elementinhalts, beispielsweise von FONT_FILENAME
        if (pos.go("PARAMS/FONT/FONT_FILENAME")) {
            filename = pos.getContent();
            pos.back();
        }

         // Ausgabe der ermittelten Werte
        System.Console.Out.WriteLine("TEXT: " + txt);
        System.Console.Out.WriteLine("font filename: " + filename);

//      assertEquals("Arial.ttf", filename); 
    }

Here is the call graph for this function:

void Example1::testWrite (  ) [inline]

Write exampe XML file.

Definition at line 52 of file Example1.cs.

References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::create(), XMLStorage::XMLPos::setContent(), and XMLStorage::XMLDoc::writeFile().

Referenced by Main().

    {
        XMLDoc doc = new XMLDoc();
        XMLPos pos = new XMLPos(doc);

         // Zusammenstellen der XML-Struktur im Dokument 'doc'
        pos.create("PARAMS");
          pos.create("TEXT");
            pos.setContent("Testgruppe\nZeile 2", true);
          pos.back(); // </TEXT>

          pos.create("COLOR");
            pos.create("RED");
            pos.setContent("234");
            pos.back(); // </RED>

            pos.create("GREEN");
            pos.setContent("22");
            pos.back(); // </GREEN>

            pos.create("BLUE");
            pos.setContent("33");
            pos.back(); // </BLUE>
          pos.back(); // </COLOR>

          pos.create("FONT");
            pos.create("FONT_FILENAME");
            pos.setContent("Arial.ttf");
            pos.back(); // </FONT_FILENAME>

            pos.create("SIZE");
            pos.setContent("12");
            pos.back(); // </SIZE>
          pos.back(); // </FONT>
        pos.back(); // </PARAMS>

         // Schreiben der XML-Datei
        doc.writeFile("example1.xml");
    }

Here is the call graph for this function:


The documentation for this class was generated from the following file: