//生成XML XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("Data"); xmlDoc.AppendChild(root); foreach (var item in agentStateDic) { XmlElement element = xmlDoc.CreateElement("Agent"); element.SetAttribute("Code", item.Key); element.SetAttribute("Status", item.Value); root.AppendChild(element); } rtn = xmlDoc.InnerXml;
Code: