SpriteLibrary
SpriteLibrary
SpriteLibrary
SpriteDatabase Class
SpriteDatabase Methods
CloneByXMLSerializing(T) Method
GetImageFromName Method
GetImageNames Method
LoadObjectFromXmlFile(T) Method
OpenEditWindow Method
ReadFromXmlFile(T) Method
ReadFromXmlString(T) Method
Save Method
SetIcon Method
SetSnapGridSize Method
SpriteFromName Method
SpriteNames Method
WriteToXmlFile(T) Method
WriteToXMLString(T) Method

# SpriteDatabase ReadFromXmlFile T Method

Reads an object instance from an XML file.

Object type must have a parameterless constructor.

Namespace: SpriteLibrary
Assembly: SpriteLibrary (in SpriteLibrary.dll) Version: 1.0.0.6 (1.0.0.6)
Syntax
C#
Copy

    public static T ReadFromXmlFile<T>(
    	string filePath
    )
    where T : new()

#### Parameters

filePath
  Type: System
  String
  The file path to read the object instance from.

#### Type Parameters

T
  The type of object to read from the file.

#### Return Value

Type: T
Returns a new instance of the object read from the XML file.
Examples
XML Serialization takes an object (a class, a variable, or whatever) and will store any public values in XML. You can choose to save the resulting XML as a string, or to save it to a file. This function reads in a file that probably has been written by WriteToXmlFile
T
(String, T).
Copy

    MyClass MyVariable = new MyClass();
    MyVariable.Name = "StoreThis!";

    SpriteDatabase.WriteToXmlFile<MyClass>("c:\xml_file.xml", MyClass);

Now that we have an XML file, we can use this code to load it.
Copy

    MyClass MyVariable = SpriteDatabase.ReadFromXmlFile<MyClass>("c:\xml_file.xml");
    Console.WriteLine(MyVariable.Name);

See Also

#### Reference

SpriteDatabase Class
SpriteLibrary Namespace