Home > APIs > AppServer API > Examples > Connection and System Status > Get Configuration Information
Get Configuration Information
The configuration information on a K2 Client is stored in the file C:\profile\config\config.xml. It has a lot of information in it, but the basic structure looks like this:
Below is sample code demonstrating how to retrieve the configuration data and extract the id and channelIndex information for each channel:
[C#] // create ConfigMgr string xmlConfig = ""; IConfigMgr iconfigMgr = iappServer.CreateConfigMgr(appName); // get config xml document iconfigMgr.GetConfigXml(out xmlConfig); // load the xml string into a native XmlDocument XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlConfig); // setup a namespace manager to parse the xml doc XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xmlDoc.NameTable); namespaceManager.AddNamespace("ns", "x-schema:#Schema1"); // get all channels XmlNodeList channelList = xmlDoc.SelectNodes(("./Config/Channel"), namespaceManager); if (channelList.Count > 0) { IEnumerator channelNodeEnum = channelList.GetEnumerator(); bool bMoreChannels = channelNodeEnum.MoveNext(); // loop thru channels to find their id and channelIndex values Console.WriteLine("Channel names:"); do { XmlNode channelNode = (XmlNode)channelNodeEnum.Current; string channelId = channelNode.Attributes.GetNamedItem("id").Value; int channelIndex = Int32.Parse(channelNode.Attributes.GetNamedItem("channelIndex").Value); Console.WriteLine("channel index: {0} id: {1}", channelIndex, channelId); bMoreChannels = channelNodeEnum.MoveNext(); } while (bMoreChannels); }