开发者

how to specify xml element having a xml attribute

开发者 https://www.devze.com 2023-01-28 08:22 出处:网络
What should be the class structure such that it serializes in the format given below <Header> <Version environment=\"debug\">2.2</Version&开发者_JAVA技巧gt;

What should be the class structure such that it serializes in the format given below

 <Header>
          <Version environment="debug">2.2</Version&开发者_JAVA技巧gt;
 </Header>

[XmlRoot]
public class Header
{
   [XmlElement]
   public string Version{get;set;}
}


[XmlRoot]
public class Header
{
    [XmlElement]
    public Version Version { get; set; }
}

public class Version
{
    [XmlAttribute("environment")]
    public String Environment { get; set; }

    [XmlText]
    public String Value { get; set; }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消