public void loadXML(string xmlFile) { xdoc = XDocument.Load(xmlFile); if (xdoc == null) { throw (new Exception("Unable to load XML file: " + xmlFile)); } fullPathFileName = xmlFile; var sensorNode = xdoc.Root.Elements("Sensors"); foreach (XElement el in sensorNode.Descendants("Sensor")) { string ip = el.Attribute("ipAddress").Value; byte groupID = byte.Parse(el.Attribute("groupid").Value); byte timeOut = byte.Parse(el.Attribute("timeout").Value); _controller.addModule(ip, 1, groupID, timeOut); } }