一、根节点的ElementName的修改
通过为XML序列化添加XmlRootAttribute
XmlRootAttribute root = new XmlRootAttribute();
root.ElementName = "修改名称";
XmlSerializer mySerializer = new XmlSerializer(typeof(Data), root);
二、一般节点的ElementName的修改
XmlElementAttribute myElementAttribute = new XmlElementAttribute();
myElementAttribute.ElementName= "修改名称";
XmlAttributes myAttributes = new XmlAttributes();
myAttributes.XmlElements.Add(myElementAttribute);
XmlAttributeOverrides myOverrides = new XmlAttributeOverrides();
myOverrides.Add(typeof(Data), "lsarea", myAttributes);
XmlSerializer mySerializer = new XmlSerializer(typeof(Data), myOverrides);
例子:
Data fdadf = new Data();
area test = new area();