C# Xml反序列化-具有属性和值的元素
我不太确定如何反序列化以下内容:C# Xml反序列化-具有属性和值的元素,c#,xml,xml-serialization,C#,Xml,Xml Serialization,我不太确定如何反序列化以下内容: <property> <price display="yes" plusSAV="no" tax="yes">1000000</price> ... </property> [Serializable] public class Price : BaseDisplayAttribute, IDataModel { [XmlElement("pr
<property>
<price display="yes" plusSAV="no" tax="yes">1000000</price>
...
</property>
[Serializable]
public class Price : BaseDisplayAttribute, IDataModel
{
[XmlElement("price")]
public string PriceValueString { get; set; }
[XmlAttribute("plusSAV")]
public string PlusSAVString { get; set; }
[XmlAttribute("tax")]
public string TaxString { get; set; }
....
}
然后在Price类中,我有以下内容:
<property>
<price display="yes" plusSAV="no" tax="yes">1000000</price>
...
</property>
[Serializable]
public class Price : BaseDisplayAttribute, IDataModel
{
[XmlElement("price")]
public string PriceValueString { get; set; }
[XmlAttribute("plusSAV")]
public string PlusSAVString { get; set; }
[XmlAttribute("tax")]
public string TaxString { get; set; }
....
}
所有属性都已正确反序列化,但price元素未正确反序列化。我在这里申报正确了吗
谢谢试着这样使用
[XmlText]
public string PriceValueString { get; set; }
是的,就是这样。事实上,我只是想出来了,然后回来发布答案,但看起来你比我抢先一步。谢谢塞尔曼:)如果我能帮忙,我很高兴:)