public static QueryCondition GetQueryConditionByKey(string filePath, string key) { XmlDocument document = new XmlDocument(); document.Load(filePath); XmlNode node = document.SelectSingleNode("/Items/Item[@key='" + key + "']"); QueryCondition condition = new QueryCondition(); condition.Key = node.Attributes["key"].Value; condition.Value = node.Attributes["value"].Value; condition.Text = node.Attributes["text"].Value; condition.Type = node.Attributes["type"].Value; return condition; }
public static IList<QueryCondition> GetQueryCondition(string filePath) { XmlDocument document = new XmlDocument(); document.Load(filePath); XmlNodeList list = document.SelectNodes("/Items/Item"); IList<QueryCondition> list2 = new List<QueryCondition>(); foreach (XmlNode node in list) { QueryCondition condition = new QueryCondition(); condition.Key = node.Attributes["key"].Value; condition.Value = node.Attributes["value"].Value; condition.Text = node.Attributes["text"].Value; condition.Type = node.Attributes["type"].Value; list2.Add(condition); } return list2; }