Public Member Functions | Static Private Member Functions

Example2 Class Reference

Example to use XMLStorage for writing and reading XML files containing numbers. More...

List of all members.

Public Member Functions

void testWrite ()
 Write an example XML file to disk.
void testRead ()
 Read the example file back again.

Static Private Member Functions

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

Detailed Description

Example to use XMLStorage for writing and reading XML files containing numbers.

Author:
martin

Definition at line 48 of file Example2.cs.


Member Function Documentation

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

Main function of Example2.

Parameters:
argsunused command line arguments

Definition at line 108 of file Example2.cs.

References testRead(), and testWrite().

    {
        Example2 me = new Example2();

        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 Example2::testRead (  ) [inline]

Read the example file back again.

Definition at line 83 of file Example2.cs.

References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::get(), and XMLStorage::XMLPos::go().

Referenced by Main().

    {
         // Einlesen des XML-Files
        XMLDoc doc = new XMLDoc("example2.xml");

        XMLPos pos = new XMLPos(doc);
        String filename = "";

         // Abfrage eines Attributwerts, beispielsweise von "font-filename"
        if (pos.go("PARAMS/FONT")) {
            filename = pos.get("font-filename");
            pos.back();
        }

         // Ausgabe des ermittelten Werts
        System.Console.Out.WriteLine("font filename: " + filename);

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

Here is the call graph for this function:

void Example2::testWrite (  ) [inline]

Write an example XML file to disk.

Definition at line 53 of file Example2.cs.

References XMLStorage::XMLStringRef::assign(), XMLStorage::XMLIntRef::assign(), XMLStorage::XMLPos::back(), XMLStorage::XMLPos::create(), XMLStorage::XMLPos::put(), 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.put("text", "Testgruppe");

          pos.create("COLOR");
            new XMLIntRef(pos, "red").assign(234);
            new XMLIntRef(pos, "green").assign(22);
            new XMLIntRef(pos, "blue").assign(33);
          pos.back(); // </COLOR>

          pos.create("FONT");
            new XMLStringRef(pos, "font-filename").assign("Arial.ttf");
            new XMLIntRef(pos, "size").assign(12);
            pos.back(); // </SIZE>
          pos.back(); // </FONT>
        pos.back(); // </PARAMS>

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

Here is the call graph for this function:


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