The type that you pass to XmlSerializer
as the root type represents the root of the xml. You are passing typeof(attribute)
. This type does not match the xml; you should be passing typeof(Parameter)
i.e. a type that looks like the xml. For example:
[XmlRoot("parameter")]
public class Parameter {
[XmlElement("component")]
public Component Component {get;set;}
}
(edit, see comments) another file
public class Component {
[XmlElement("attributes")]
public List<Attribute> Attributes {get;set;}
}
with:
XmlSerializer ser = new XmlSerializer(typeof(Parameter));
var mainobj = (Parameter)ser.Deserialize(myFileStream);