XmlFile ClassDelta Engine Documentation
Loads and saves XmlData to file View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Content.Xml XmlFile

Namespace: DeltaEngine.Content.Xml
Assembly: DeltaEngine.Content.Xml (in DeltaEngine.Content.Xml.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class XmlFile

The XmlFile type exposes the following members.

Constructors

  NameDescription
Public methodXmlFile(Stream)
Initializes a new instance of the XmlFile class
Public methodXmlFile(String)
Initializes a new instance of the XmlFile class
Public methodXmlFile(XmlData)
Initializes a new instance of the XmlFile class
Top
Methods

  NameDescription
Public methodSave
Public methodToMemoryStream
Top
Properties

  NameDescription
Public propertyRoot
Top
Remarks

Tests: DeltaEngine.Content.Xml.Tests.XmlFileTests
Examples

3 unit tests call DeltaEngine.Content.Xml.XmlFile
[Test]
public void XmlDataConstructor()
{
    var data = new XmlData("name");
    var file = new XmlFile(data);
    Assert.AreEqual(data, file.Root);
}
[Test]
public void LoadXmlFromStream()
{
    var memoryStream = new MemoryStream();
    var writer = new BinaryWriter(memoryStream);
    writer.Write(new XmlData("MyData").ToString());
    memoryStream.Seek(0, SeekOrigin.Begin);
    var file = new XmlFile(memoryStream);
    Assert.AreEqual("MyData", file.Root.Name);
}
[Test]
public void SavingAndLoadingLeavesItUnchanged()
{
    XmlData data = CreateTestXmlData();
    var file = new XmlFile(data);
    file.Save("file.xml");
    XmlData loaded = new XmlFile("file.xml").Root;
    Assert.AreEqual(data.ToString(), loaded.ToString());
}
See Also