有如下的XML及反序列化对象。问题是我想把MenuItem中的children属性的首字母大写,即改成Children,但如果大写就无法反序列化出子节点,请问有什么方法可以搞定?
<?xml version="1.0" encoding="utf-8" ?> <menus> <menu name="a"> <children> <menu name="a1" /> <menu name="a2" /> <menu name="a3" /> </children> </menu> <menu name="b"> <children> <menu name="b1" /> <menu name="b2" /> <menu name="b3"> <children> <menu name="b31" /> <menu name="b32" /> <menu name="b33" /> </children> </menu> </children> </menu> </menus>
using System.Xml.Serialization; using System.Xml.Schema; [XmlRootAttribute(ElementName = "menus", Namespace = "", IsNullable = false)] public class MenuItems { [XmlElementAttribute("menu", Form = XmlSchemaForm.Unqualified)] public MenuItem[] Items { get; set; } } [XmlTypeAttribute(AnonymousType = true)] public class MenuItem { [XmlAttributeAttribute("name")] public string Name { get; set; } [XmlArrayItemAttribute("menu", typeof(MenuItem), Form = XmlSchemaForm.Unqualified, IsNullable = false)] public MenuItem[] children { get; set; } }
HUX布斯
慕尼黑5688855
慕容708150
白衣染霜花
料青山看我应如是
守着一只汪