I have a table in my database that has a 3 fields.
RuleID | RuleName | Rule
the ruleID is a randomly generated string of characters, RuleName is the name the user gives to the rule, and the Rule field is about 600 characters long and is just XML text.
I want to read that Rule field from the database and use it inside the function below.
This function loads an xml file from a static location and parses out some information to a context menu.
BUt i'm culeless on how to have the function read the xml info found inside my database.
I'm a rookie at C# so be gentle
RuleID | RuleName | Rule
the ruleID is a randomly generated string of characters, RuleName is the name the user gives to the rule, and the Rule field is about 600 characters long and is just XML text.
I want to read that Rule field from the database and use it inside the function below.
Code:
private static List<MenuItem> LoadRules(bool evaluationType) { //string path = HttpContext.Current.Server.MapPath(string.Format("/Rules/{0}/{1}/", ip, evaluationType ? "Evaluation" : "Execution")); List<MenuItem> list = new List<MenuItem>(); //if(Directory.Exists(path)) { //foreach(string file in Directory.GetFiles(path)) { XmlDocument xml = new XmlDocument(); xml.Load(file); XmlNamespaceManager m = new XmlNamespaceManager(xml.NameTable); m.AddNamespace("x", xml.DocumentElement.NamespaceURI); XmlNode rule = xml.SelectSingleNode("/x:codeeffects/x:rule", m); list.Add(new MenuItem( rule.Attributes["id"].Value, rule.SelectSingleNode("x:name", m).InnerText, rule.SelectSingleNode("x:description", m) == null ? null : rule.SelectSingleNode("x:description", m).InnerText)); } } return list; }
BUt i'm culeless on how to have the function read the xml info found inside my database.
I'm a rookie at C# so be gentle
Comment