<Root>
<Channel name="最热">
<Infos>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
</Infos>
</Channel>
</Root>
这种结构的的XML如何用反序列化读取,求代码
<Channel name="最热">
<Infos>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
<Info>
<Title>实习期与试用期什么不同</Title>
<Url>http://club.cqjob.com/read-htm-tid-31420.html</Url>
<Date>2011-09-30</Date>
<Img>
<Src>http://club.cqjob.com/images/face/1.gif?1316254800</Src>
<Width>120</Width>
<Height>120</Height>
</Img>
</Info>
</Infos>
</Channel>
</Root>
这种结构的的XML如何用反序列化读取,求代码
解决方案 »
- 数据源绑定以及数据库读取保存问题
- 什么的任务是将来源不同的编译单元装配成一个可执行程序
- 请教高手c# 水晶报表默认纸张设置为宅急送?
- 怎么控制datagridview的某一column只能录入数字和小数点
- 网页中使用自己的 ASCX 控件,可以执行,不能发布
- 权限管理的问题,走入了死胡同,请求高人援手!
- 什么样才算是后台程序?
- 如何在assembly取得应用程序的路径
- Microsoft Visual Studio 2008窗体开不开
- 在线等待,我初学.net。做了一个网站,不知道怎样配置服务器。
- 请教一个用httpwebrequest关于登陆有验证码的网站。
- ( C# )定义char a='1';int b=convert.toint16(a);为什么输出的是49而不是1?
举个例子可以不, Channel 类和info类怎么写
[Serializable]
public class ClubConfigInternal
{
public List<Infos> Channel { get; set; }
} [Serializable]
public class Infos
{
//这里怎么写
} [Serializable]
public class Info
{
//这里怎么写
} [Serializable]
public class Img
{
//这里怎么写
}
{
public string title;
public string url;
public string date;
public string img;
} public class Infos
{
public List<Info> Allinfos = new List<Info>();
} [XmlRoot("Channel")]
public class Channel
{
private string name; [XmlElement("Infos")]
public List<Infos> children = new List<Infos>(); [XmlAttribute("Name")]
public string Name
{
get { return this.name; }
set { this.name = value; }
} }
root.Name = "最热";
root.children = new List<Infos>();
Infos infos = new Infos();
Info info = new Info();
info.date = "2011-9-9";
info.img="hooot:asdfasdfkl";
info.title="title";
info.url="url=::::::";
infos.Allinfos.Add(info);
root.children.Add(infos);
//root.children = infos;
XmlSerializer ser = new XmlSerializer(typeof(Channel));
FileStream fs = new FileStream(@"d:\aaaa.xml", FileMode.Create, FileAccess.Write); XmlTextWriter writer = new XmlTextWriter(fs, Encoding.UTF8);
XmlSerializerNamespaces xmln = new XmlSerializerNamespaces();
xmln.Add(string.Empty, string.Empty);
ser.Serialize(writer, root,xmln);
fs.Close();
public class TableModel
{
private string _engName; //表的英文名
private string _chnName; //表的中文名
private List<ColumnModel> _columns = new List<ColumnModel>(); //字段结构
}
public class ColumnModel
{
private string _engName; //表中字段名
private string _chnName;
private bool _isPrimary;
private FieldType _fieldType;
private bool _callstoredprocedure;
}
所有这些要封装的,还有构造函数,我这里都省略了。
xml<?xml version="1.0" encoding="utf-8"?>
<TableModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<EngName>model</EngName>
<ChnName>订单处理后表格</ChnName>
<Columns>
<ColumnModel>
<EngName>Material_Package_Number</EngName>
<ChnName>号码</ChnName>
<IsPrimary>false</IsPrimary>
<FieldType>CHAR</FieldType>
<Callstoredprocedure>false</Callstoredprocedure>
<Unique>false</Unique>
<Visible>true</Visible>
</ColumnModel>
<ColumnModel>
<EngName>line</EngName>
<ChnName>产线</ChnName>
<IsPrimary>false</IsPrimary>
<FieldType>CHAR</FieldType>
<Callstoredprocedure>false</Callstoredprocedure>
<Unique>false</Unique>
<Visible>true</Visible>
</ColumnModel>
</Columns>
</TableModel>将就着看看吧
xml跟类里面要一一对应,可以用来list来描述字段结构