如何Xml序列化嵌套在值C#中的属性

时间:2019-07-09 08:07:30

标签: c# xml

如何在元素值中获取属性值?我正在寻找以下结果:

        <Item>
          <Element Attribute="Attribute value">Element value</Element>
        </Item>

当我序列化以下类时,属性成为Item的一部分:

[Serializable]
public class Item
{
    [XmlElement("Element")]
    public string Element;

    [XmlAttribute("Attribute")]
    public string Attribute;
}

0 个答案:

没有答案