Example to use XMLStorage for writing and reading XML files. More...
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 Example3. |
Example to use XMLStorage for writing and reading XML files.
Definition at line 48 of file Example3.cs.
static void Example3::Main | ( | string[] | args ) | [inline, static, private] |
Main function of Example3.
args | unused command line arguments |
Definition at line 105 of file Example3.cs.
References testRead(), and testWrite().
{ Example3 me = new Example3(); try { me.testWrite(); me.testRead(); } catch(Exception e) { System.Console.Error.WriteLine(e); System.Console.Error.WriteLine(e.StackTrace); } }
void Example3::testRead | ( | ) | [inline] |
Read the example file back again.
Definition at line 72 of file Example3.cs.
References XMLStorage::XMLPos::back(), XMLStorage::XMLPos::get(), XMLStorage::XMLPos::go(), XMLStorage::XMLInt::intValue(), and XMLStorage::XMLDoc::readFile().
Referenced by Main().
{ XMLDoc doc = new XMLDoc(); // Einlesen des XML-Files doc.readFile("example3.xml"); XMLPos pos = new XMLPos(doc); int stopbits = 0; string parity = ""; // Abfrage der Attributwerte des Elements "Y_ACHSE" if (pos.go("Y_ACHSE")) { stopbits = new XMLInt(pos, "Stopbits").intValue(); parity = pos.get("Parity"); pos.back(); } // Ausgabe der ermittelten Werte System.Console.Out.WriteLine("Stopbits: " + stopbits); System.Console.Out.WriteLine("Parity: " + parity); // assertTrue("Stopbits", 1==stopbits); // assertEquals("Parity", "N", parity); }
void Example3::testWrite | ( | ) | [inline] |
Write an example XML file to disk.
Definition at line 53 of file Example3.cs.
References 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("Y_ACHSE"); new XMLIntRef(pos, "Stopbits").assign(1); pos.put("Parity", "N"); pos.back(); // Schreiben der XML-Datei doc.writeFile("example3.xml"); }