XmlSerializer 混合内容反序列化

发布于 2024-08-28 21:30:55 字数 215 浏览 5 评论 0原文

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

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

How do I setup my class to deserialize the following mixed content xml?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

征棹 2024-09-04 21:30:55

这应该可以做到。

[System.Xml.Serialization.XmlElementAttribute("match")]
公共匹配[]匹配{
  获取{
    返回这个._match;
  }
  设置{
    this._match = 值;
  }
}

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

This should do it.

[System.Xml.Serialization.XmlElementAttribute("match")]
public match[] match {
  get {
    return this._match;
  }
  set {
    this._match = value;
  }
}

///
[System.Xml.Serialization.XmlTextAttribute()]
public string[] Text {
  get {
    return this.textField;
  }
  set {
    this.textField = value;
  }
}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文