Ninja Database Pro
ExportTableToXml<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : ExportTableToXml<T> Method
Export all records of a table to an XML string
Syntax
Public Function ExportTableToXml(Of T As {Class, New})() As String
Dim instance As NinjaDbPro
Dim value As String
 
value = instance.ExportTableToXml(Of T)()
public string ExportTableToXml<T>()
where T: class, new()
public:
String^ ExportTableToXmlgeneric<typename T>
(); 
where T: ref class, gcnew()

Type Parameters

T
Example
NinjaDbPro db = new NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName");
            db.Storage = new FileDatabase(); 
             
            //Licensed Mode
            //db.UserName = "John Smith 101224";
            //db.LicenseKey = "aousdf832jasf==";
             
            db.OpenDatabase();
             
            Person person1 = new Person();
            person1.Name = "John";
            db.Save(person1);
             
            Person person2 = new Person();
            person2.Name = "Jane";
            db.Save(person2);
             
            //Export to a string
            string result = db.ExportTableToXml<Person>();
             
            //Save to a file
            System.IO.File.WriteAllText("Persons.xml", result);
             
            db.CloseDatabase();
             
            //Delete the database
            db.DeleteEntireDatabase();
             
            db.OpenDatabase();
             
            //Import it back in
            db.ImportTableFromXml<Person>(result);
             
            Person personCopy = db.Load<Person>(person1.PersonId);
Dim db As New NinjaDbPro("MyDatabaseDirectory", "MyDatabaseName")
            db.Storage = New FileDatabase()
             
            'Licensed Mode
            'db.UserName = "John Smith 101224";
            'db.LicenseKey = "aousdf832jasf==";
             
            db.OpenDatabase()
             
            Dim person1 As New Person()
            person1.Name = "John"
            db.Save(person1)
             
            Dim person2 As New Person()
            person2.Name = "Jane"
            db.Save(person2)
             
            'Export to a string
            Dim result As String = db.ExportTableToXml(Of Person)()
             
            'Save to a file
            System.IO.File.WriteAllText("Persons.xml", result)
             
            db.CloseDatabase()
             
            'Delete the database
            db.DeleteEntireDatabase()
             
            db.OpenDatabase()
             
            'Import it back in
            db.ImportTableFromXml(Of Person)(result)
             
            Dim personCopy As Person = db.Load(Of Person)(person1.PersonId)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NinjaDbPro Class
NinjaDbPro Members