How to deserialized xml?
-
Thursday, May 03, 2012 7:19 AMhi all ,
i am creating xml file using below code
Root = XD.AppendChild(XD.CreateElement("Root"));XmlNode name= Root.AppendChild(XD.CreateElement(" name "));XmlNode UserName = Root.AppendChild(XD.CreateElement("UserName"));Root.AppendChild(Cloud);Root.AppendChild(CloudUserName);//XmlAttribute ChildAtt = Child.Attributes.Append(XD.CreateAttribute("Attribute"));Cloud.InnerText = test.ServiceName;CloudUserName.InnerText = test.UserName;CloudKey.InnerText = test.Password;XD.Save(appStartPath);
now how to do deserialization of this data?
All Replies
-
Thursday, May 03, 2012 9:31 AM
Well if you saved the XmlDocument XD to appStartPath and want to reload it then simply call XD.Load. If you want to do XML Deserialization with XmlSerializer then of course you can do that as well, with e.g.
XmlSerializer ser = new XmlSerializer(typeof(Foo));
Foo foo;
using (XmlReader xr = XmlReader.Create(appStartPath))
{
foo = (Foo).ser.Deserialize(xr);
}
If that does not help then please explain in more detail as to what kind of deserialization you want to do and why you mix DOM and deserialization, that is unusual.
MVP Data Platform Development My blog

