Original link:
http://www.cnblogs.com/wysky/archive/2007/12/29/1020217.html
Problems encountered are different class names and XML node error: undue node <BaseConfigInfo> and so
===================
deserialization when the default .NET XML corresponding to the name of the class name, such as:
< Config >
< Name > Tom </ Name >
< Age > 21 </ Age >
</ Config >
Corresponding class are:
We can change this default setting by XMLRootAttribute categories:
(From: http: //www.cnblogs.com/dudu/archive/2004/03/24/4064.html)
attached to an FAQ
===================
deserialization when the default .NET XML corresponding to the name of the class name, such as:
< Config >
< Name > Tom </ Name >
< Age > 21 </ Age >
</ Config >
Corresponding class are:
[Serializable]
public class Config
{
[XmlAttribute("Name")]
public string Name;
[XmlAttribute("Age")]
public int Age;
}
public class Config
{
[XmlAttribute("Name")]
public string Name;
[XmlAttribute("Age")]
public int Age;
}
We can change this default setting by XMLRootAttribute categories:
[The Serializable, the XmlRoot (ElementName
=
" Config " )] // namely: XMLConfig Config node corresponding to the XML configuration public class XMLConfig { [XmlAttribute ( " the Name " )] public String the Name; [XmlAttribute ( " Age " )] public int Age; }
(From: http: //www.cnblogs.com/dudu/archive/2004/03/24/4064.html)
attached to an FAQ
Reproduced in: https: //www.cnblogs.com/wysky/archive/2007/12/29/1020217.html