類型:我將如何詮釋這個.NET類型以連載從以下XML/deserialise到/,使用的System.Xml.Serialization
public class Foo
{
public string Bar { get; set; }
public string Fred { get; set; }
}
實例
Foo x = new Foo { Bar = "Hi", Fred = "hey yourself" };
的XML:
<Foo>
<Bar>Hi</Bar>
<John> <!-- Note extra layer -->
<Fred>hey there</Fred>
</John>
</Foo>
注意額外John
標籤,但沒有對John
創建一個特殊類型。如果我不能註釋它,我該如何以編程方式控制序列化過程。
哪裏約翰標籤從何而來?你的意思是你想嵌套一個標籤與其他自定義標籤? –
這就是我想要額外標籤的問題。 –
我認爲你應該使用XmlDocument並編寫自己的代碼,而不是使用XmlSerializer。也許你最後的選擇 –