首页 > 代码库 > C# XmlSerializer实现序列化浅析

C# XmlSerializer实现序列化浅析

C# XmlSerializer的出处:

  1. using System.Xml.Serialization; 

C# XmlSerializer实现序列化:

XmlSerializer xml = new XmlSerializer(typeof(Test));  
FileStream fs = new FileStream(@"c:\t.xml",FileMode.Create);  
xml.Serialize(fs, t);  
fs.Close(); 

C# XmlSerializer实现反序列化:

FileStream fs = new FileStream(@"c:\t.xml", FileMode.Open);  
XmlSerializer xml = new XmlSerializer(typeof(Test));  
Test t = (Test)xml.Deserialize(fs)

 

其他参考:

C# XML反序列化与序列化举例:XmlSerializer http://blog.csdn.net/philosophyatmath/article/details/28593153
XmlSerializer 对象的Xml序列化和反序列化 http://www.cnblogs.com/yukaizhao/archive/2011/07/22/xml-serialization.html
使用XML LINQ查询和转换XML http://blog.csdn.net/gentle_wolf/article/details/2724208
Convert XElement to XmlNode http://www.cnblogs.com/chenxizhang/archive/2010/03/24/1693383.html

C# XmlSerializer实现序列化浅析