C# 使用XML类属性,如何用内部文本和属性表示XML标记?

C# 使用XML类属性,如何用内部文本和属性表示XML标记?,c#,xml,xml-serialization,C#,Xml,Xml Serialization,假设我有这个XML文件: <weather> <temp>24.0</temp> <current-condition iconUrl="http://....">Sunny</current-condition> </weather> 表示“temp”标记是直接的。但是,给定一个既有内部文本又有属性的类似于标记的当前条件,如何表示内部文本 我可能把这件事复杂化了,所以请随意提出一个替代方案 使用[XmlTex

假设我有这个XML文件:

<weather>
   <temp>24.0</temp>
   <current-condition iconUrl="http://....">Sunny</current-condition>
</weather>
表示“temp”标记是直接的。但是,给定一个既有内部文本又有属性的类似于标记的当前条件,如何表示内部文本


我可能把这件事复杂化了,所以请随意提出一个替代方案

使用
[XmlText]
描述内部文本内容

public class CurrentCondition
{
    [XmlAttribute("iconUrl")
    public string IconUrl { get; set; }

    // Representation of Inner Text:
    [XmlText]
    public string ConditionValue { get; set; }
}

我在MSDN上看到过几次;这证明我确实没有仔细阅读!谢谢
public class CurrentCondition
{
    [XmlAttribute("iconUrl")
    public string IconUrl { get; set; }

    // Representation of Inner Text:
    [XmlText]
    public string ConditionValue { get; set; }
}