【问题标题】:XmlSerializer Mixed Content Deserialization [duplicate]XmlSerializer 混合内容反序列化 [重复]
【发布时间】:2010-04-15 19:06:59
【问题描述】:

如何设置我的类以反序列化以下混合内容 xml?

<employee>
  <name>John Doe</name>
  <remark>He is a <match>tall</match> and handsome man</remark>
</employee>

【问题讨论】:

    标签: c# .net xmlserializer mixed


    【解决方案1】:

    应该这样做。

    [System.Xml.Serialization.XmlElementAttribute("match")]
    公共匹配[]匹配{
    得到 {
    返回 this._match;
    }
    设置 {
    this._match = value;
    }
    }

    ///
    [System.Xml.Serialization.XmlTextAttribute()]
    公共字符串[] 文本 {
    得到 {
    返回 this.textField;
    }
    设置 {
    this.textField = 值;
    }
    }

    【讨论】:

    • 但是这里你缺少内容的顺序,你正在拆分文本并匹配到不同的数组。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-17
    相关资源
    最近更新 更多