Serialization encounter "undue node"

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:
[Serializable]
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

Guess you like

Origin blog.csdn.net/weixin_30487317/article/details/94961445