So I was speaking to Mendhak earlier about this and whether xPath would be better. So heres the code:
Code:private void PopulateList(String SourceType, String OutputType) { //Populate The ListOfSubRules Property using LINQ to XML XDocument XMLDataStore = XDocument.Load("DataStore.xml"); var XMLSubRules = from XMLSubRule in XMLDataStore.Descendants("SubRule") where (XMLSubRule.Attribute("SourceType").Value == SourceType && XMLSubRule.Attribute("OuputType").Value == OutputType) select new { Expression = XMLSubRule.Element("Expression").Value, OpeningElement = XMLSubRule.Element("OpeningElement").Value, ClosingElement = XMLSubRule.Element("ClosingElement").Value }; foreach (var XMLSubRule in XMLSubRules) { SubRule SubRuleItem = new SubRule(XMLSubRule.Expression, XMLSubRule.OpeningElement, XMLSubRule.ClosingElement); ListOfSubRules.Add(SubRuleItem); } }




Reply With Quote