0
我有一個看起來像這樣的XML:XML反序列化
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<Items>
<Category Name="Alfa">
<Item Name="A1" Signature="3136323700000000"/>
<Item Name="A2" Signature="3136333400000000"/>
<Item Name="A3" Signature="3136323800000000"/>
<Item Name="A4" Signature="3136333300000000"/>
... More Items
</Category>
<Category Name="Beta">
<Item Name="B1" Signature="3136323700000000"/>
<Item Name="B2" Signature="3136333400000000"/>
<Item Name="B3" Signature="3136323800000000"/>
<Item Name="B4" Signature="3136333300000000"/>
... More Items
</Category>
... More Categories
</Items>
類我想用反序列化它看起來像這樣:
public sealed class Item
{
private String m_Category;
private String m_Name;
private String m_Signature;
public String Category
{
get { return m_Category; }
}
public String Name
{
get { return m_Name; }
}
public String Signature
{
get { return m_Signature; }
}
public Item(String category, String name, String signature)
{
m_Category = category;
m_Name = name;
m_Signature = signature;
}
}
我如何反序列化以便Category屬性從父元素的Name屬性中獲取?如果不可能,我可以使用哪種替代方法?
Downvoter,care to comment? – I4V 2013-05-03 12:55:41
'GameItem'從哪裏來?...? – dtsg 2013-05-03 12:59:21
@Duane這是在OP的問題。我看到他更新了,我也是。這是否是爲了低調? – I4V 2013-05-03 13:00:25