XML文件名
<?xml version="1.0" encoding="utf-8"?> <Config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Enabled>true</Enabled> <serverURL>http://127.0.01/Version.xml</serverURL> <updateFileList updateInfo="更新說明信息"> <localFile fileName="bb.exe" fileVersion="" /> </updateFileList> </Config>
程序代碼
XmlSerializer xmlSerializer = new XmlSerializer(typeof(configuration)); StreamWriter streamWriter = new StreamWriter(file); xmlSerializer.Serialize(streamWriter, this); streamWriter.Close();
出現錯誤
XML 文檔(2, 2)中有錯誤:不應有 <xml xmlns=''>
原因是因為:xml的根節點(Config)和對象名(configuration)不一樣導致的不能反序列化,只要請其中一個名稱改為和另一個一樣就可以通過
本文引用源出處 http://www.cnblogs.com/ZQJia/p/4275214.html,如有侵權請告知本人。