xml反序列化很方便,示例:
[XmlRoot(Root = "result")]
public class UniMsgSetResult
{
[XmlAttribute("resultCode")]
public int resultCode;
[XmlElement("uniMsgSet")]
public UniMsgSet uniMsgSet;
}...
集合类型示例:
[XmlRoot("result")]
public class GetDiskInnerResult
{
public string parentCatalogID; //String32 待查询目录的父目录ID。如果当前目录为root,则父目录ID为空。
[XmlArray("catalogList"), XmlArrayItem("catalogInfo")]
public List catalogList;// CatalogInfo[] 查询节点下的目录列表
[XmlArray("contentList"), XmlArrayItem("contentInfo")]
public List contentList; // ContentInfo[] 查询节点下的内容列表
} 1 ... ... ... ...
如果要为集合实体添加属性:
In order words, add an attribute to an object element after xml serialization,
If you want something like,
little rat old rat
The C# code is
名扬银河企业建站系统,适用于无代码基础的新手,快速搭建企业网站,程序内置了多项实用功能及插件,能够便捷的对网站进行修改、调整、优化等方面进行操作。【部分功能介绍】1、产品管理发布企业产品信息,管理企业产品,自定义产品封面图,产品详情图、文、视频,产品扩展属性自定义等。2、案例管理系统发布企业成功案例,管理成功案例,自定义案例封面图,案例详情图、文、视频,案例扩展属性自定义等。3、资讯管理系统发布企
[XmlType(“Rats”)]
public class Rats
{
[XmlAttribute(“count”)]
public int Count { get; set; }
[XmlElement(“Rat”)] // now the array element will be as same as the object element Rats.
public string[] Rat { get; set; }
}
Traditional xml array serialization would get the extra element for the array itself.
[XmlType(“Rats”)]
public class Rats
{
[XmlAttribute(“count”)]
public int Count { get; set; }
[XmlArray(“Rats”)]
[XmlArrayItem(“Rat”)]
public string[] Rat { get; set; }
}little rat old rat
以上就是C# xml反序列化的代码示例详情介绍的内容,更多相关内容请关注PHP中文网(www.php.cn)!









