读取xml文件中的数据示例
2015-12-09 17:17
281 查看
读取xml文件中的数据示例
public class WindowTypeMapItem { [XmlAttribute(AttributeName = "AssemblyName")] public string AssemblyName { get; set; } [XmlAttribute(AttributeName = "TypeName")] public string TypeName { get; set; } [XmlAttribute(AttributeName = "TypeKey")] public string Key { get; set; } [XmlAttribute(AttributeName = "Cacheable")] public bool IsCacheable { get; set; } }
XmlDocument document = new XmlDocument(); document.Load(fileName); XmlNodeList nodes = document.DocumentElement.SelectNodes("./WindowTypeMapItem"); foreach (XmlNode node in nodes) { string assemblyName = node.Attributes["AssemblyName"].Value; string typeName = node.Attributes["TypeName"].Value; string typeKey = node.Attributes["TypeKey"].Value; bool cacheable = Convert.ToBoolean(node.Attributes["Cacheable"].Value); windowTypeMapItems.Add(new WindowTypeMapItem() { AssemblyName = assemblyName, IsCacheable = cacheable, Key = typeKey, TypeName = typeName }); }
相关文章推荐
- spring mvc 415报错
- NSTimer
- 怎么把字符串的时间转换为想要的时间格式
- 43、BGP配置实验之聚合aggregate-address
- cocos2d-x 3.x相应键盘事件
- void 和 Void
- [javase学习笔记]-2.4 常量
- LibGDX 跨平台游戏开发基础教程(总目录)
- 欢迎使用CSDN-markdown编辑器
- python基础教程共60课-第20课命令行常用命令
- iOS框架介绍——N&O&P字头
- Android 实现MD5加密
- ui-router中resolve使用说明
- PC机与嵌入式开发板相互传输数据
- 【剑指offer】之第一个只出现一次的字符
- 希尔排序(ShellSort)
- Blur detection with OpenCV
- 基于CORS的geoserver同源访问策略
- MSSQL Tran 数据库事务回滚的用法
- fft练习