2007-12-26, 08:38 AM
I'm trying to deserialize an xml file from within a plugin (C#). If I use my code in a new windows application, it works. But as soon as I place it in the plugin project, it throws an error when I attempt the deserialization. I'm hoping someone can see what I'm missing.
Here is the contents of test.xml:
Code:
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace MyApp
{
public void GetTrailers()
{
XmlSerializer serializer = new XmlSerializer(typeof(TrailerList));
FileStream fs = new FileStream(@"c:\test.xml", FileMode.Open);
XmlReader reader = XmlReader.Create(fs);
TrailerList trailers = new TrailerList();
// This throws an error in the plugin.
trailers = (TrailerList)serializer.Deserialize(reader);
fs.Close();
}
[XmlRoot("records")]
public class TrailerList
{
private string mDate;
private List<cMovie> mMovies = new List<cMovie>();
[XmlAttribute("date")]
public string Date
{
get { return mDate; }
set { mDate = value; }
}
[XmlElement("movieinfo")]
public List<cMovie> Movies
{
get { return mMovies; }
set { value = mMovies; }
}
}
public class cMovie
{
private int mID;
private string mText;
[XmlAttribute("id")]
public int ID
{
get { return mID; }
set { mID = value; }
}
[XmlText]
public string Text
{
get { return mText; }
set { value = mText; }
}
}
}
Here is the contents of test.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<records date="Mon, 24 Dec 2007 00:40:01 -0800">
<movieinfo id="2460">Test 1</movieinfo>
<movieinfo id="2461">Test 2</movieinfo>
<movieinfo id="2462">Test 3</movieinfo>
<movieinfo id="2463">Test 4</movieinfo>
</records>