Ninja Database Pro
ImportTableFromXml<T> Method
Example 



KellermanSoftware.NinjaDatabasePro Namespace > NinjaDbPro Class : ImportTableFromXml<T> Method
Import records from an xml string to a table
Syntax
Public Sub ImportTableFromXml(Of T As {Class, New})( _
   ByVal xmlString As String _
) 
Dim instance As NinjaDbPro
Dim xmlString As String
 
instance.ImportTableFromXml(Of T)(xmlString)
public void ImportTableFromXml<T>( 
   string xmlString
)
where T: class, new()
public:
void ImportTableFromXmlgeneric<typename T>
( 
   String^ xmlString
) 
where T: ref class, gcnew()

Parameters

xmlString

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