读取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 });
}