Why XMLTextReader returning none when passed StringReader object to it?

3EBC

New Member
I want to deserialize the xml string into an object of the type class defined as follows\[code\] [Serializable] [XmlRoot("rt")] public class XMLSessionParameters { [XmlArrayItem("el")] public List<Elements> Elements { get; set; } } public class Elements { [XmlAttribute("nm")] public string Name { get; set; } [XmlAttribute("vl")] public string Value { get; set; } }\[/code\]Following is the XML, which I want to deserialize\[code\]<rt> <el nm="Name" vl="ABCD_test"/> <el nm="Dual" vl="AA"/> <el nm="Quad" vl="ABCD"/> <el nm="YYMMDD" vl="120614"/></rt>\[/code\]And following are the methods which I am using for deserialization of the XML string\[code\]public static XMLSessionParameters DeserializeSessionParameters(string xmlString) { XMLSessionParameters parameters = (XMLSessionParameters)Deserialize(typeof(XMLSessionParameters), xmlString); XElement root = XElement.Parse(xmlString); List<XElement> fileElements = root.Elements().ToList(); foreach (XElement fileEle in fileElements) { string xml = fileEle.ToString(); Elements ele = (Elements)Deserialize(typeof(Elements), xml); parameters.Elements.Add(ele); } return parameters; }private static object Deserialize(Type type, string XmlString){ XmlSerializer serializer = new XmlSerializer(type); StringReader stringReader = new StringReader(XmlString); XmlReader xmlReader = new XmlTextReader(stringReader); object serializedObj = serializer.Deserialize(xmlReader); return serializedObj;}\[/code\]When I pass the above mentioned XML as string and when Deserialize function is invoked, XMLReader object posseses the value as None and my program ends abruptly, without giving any exceptions.What can be the cause for such a behavior?
 
Back
Top