I am trying to find a way to take an XmlNodeList and Deserialize it.
I will need to take the XmlNodeList obj and make it ready for deserialization by converting it into something that the serializer can use.
Any Advice?
string fileLoc = @"File.xml"; XmlDocument xdoc = new XmlDocument(); xdoc.Load(fileLoc); XmlNodeList ndlist = xdoc.SelectNodes("//DConfig/ConfigValue/UrlListValues/UrlInfo"); UrlListValues myObject; XmlSerializer mySerializer = new XmlSerializer(typeof(UrlListValues)); FileStream myFileStream = new FileStream(fileLoc, FileMode.Open); // *** This is where the problem starts. Cannot cast as UrlListValues myObject = (UrlListValues)mySerializer.Deserialize(myFileStream); foreach (UrlInfo xn in myObject) { // Do stuff }
No comments:
Post a Comment