-1
序列化之后这个类的一个对象:我如何收拾我的XML代码
[XmlType("Person")] // define Type
public class Person
{
[XmlElement("PropertyType")]
public PropertyType PropertyType { get; set; }
[XmlElement("ID")]
public string ID { get; set; }
[XmlElement("Name")]
public string Name { get; set; }
[XmlElement("City")]
public string City { get; set; }
[XmlElement("Age")]
public Dictionary<object, object> Age { get; set; }
}
我有这样的代码:
<PersonenListe>
<PersonenArray>
<PersonObjekt>
<PropertyType>Unknown</PropertyType>
<ID>0</ID>
<FriendlyName>Max Man</FriendlyName>
<City>Capitol City</City>
<Age>33</Age>
<Name>
<item>
<key>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" p8:type="q1:string" xmlns:p8="http://www.w3.org/2001/XMLSchema-instance">test1</anyType>
</key>
<value>
<anyType xmlns:q1="http://www.w3.org/2001/XMLSchema" p8:type="q1:string" xmlns:p8="http://www.w3.org/2001/XMLSchema-instance">test2</anyType>
</value>
</item>
</Name>
</PersonObjekt>
</PersonenArray>
</PersonenListe>
How can I clean up it(I want to have code without this namespaces)? maybe using some attributes?
Update:
when I serialize it separetly I get:
<PersonenListe>
<PersonenArray>
<PersonObjekt>
<PropertyType>Unknown</PropertyType>
<ID>0</ID>
<FriendlyName>Max Man</FriendlyName>
<City>Capitol City</City>
<Age>33</Age>
<Name />
</PersonObjekt>
</PersonenArray>
</PersonenListe>
<?xml version="1.0"?>
<dictionary>
<item>
<key>
<string>test1</string>
</key>
<value>
<string>test2</string>
</value>
</item>
</dictionary>
不知道你所寻找的。你的意思是使用XmlAttribute? – Default 2012-01-05 12:50:10
如果删除命名空间,您希望序列化程序如何知道将哪种类型用作弱类型结构作为“Dictionary
这不是什么重要的东西,主要是清理代码) – revolutionkpi 2012-01-05 12:53:01