//prints the XML node and any subnode(s) to the console recursively private static void PrintNode(ItemNode menuItem, string tab) { Console.WriteLine(tab + menuItem.Name + ", " + menuItem.Path + (menuItem.IsActive ? " ACTIVE" : "")); if (menuItem.SubItems != null) { foreach (var subItem in menuItem.SubItems) { PrintNode(subItem, tab + "\t"); } } }
//Creates an itemnode object from a given <item> node private static ItemNode CreateNode(XElement node) { var retNode = new ItemNode(); var elName = node.Element("displayName"); var elPath = node.Element("path"); if (elName != null) { retNode.Name = elName.Value; } if (elPath != null && elPath.Attribute("value") != null) { retNode.Path = elPath.Attribute("value").Value; if (retNode.Path.Equals(_activePath)) { retNode.IsActive = true; //mark this node as active } } return(retNode); }