111,097
社区成员




XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlEl;
XmlDeclaration xmlDec=xmlDoc.CreateXmlDeclaration("1.0", "gb2312", null);
xmlDoc.AppendChild(xmlDec);
xmlDoc.CreateComment("这是英泰力接收器的配置文件 不要删除 否则后果自负");
xmlDoc.CreateComment("type是设备类型标识 1为按钮开关");
xmlEl = xmlDoc.CreateElement("YTLcn");
xmlEl.SetAttribute("type","1");
xmlDoc.AppendChild(xmlEl);
XmlNode xmlNodeList = xmlDoc.SelectSingleNode("YTLcn");
xmlDoc.CreateComment("LoopNum回路标识 1是第1个回路");
xmlEl = xmlDoc.CreateElement("Loop");
xmlEl.SetAttribute("LoopNum", "1");
xmlNodeList.AppendChild(xmlEl);
xmlNodeList = xmlDoc.SelectSingleNode("Loop");
xmlEl = xmlDoc.CreateElement("ID");
xmlNodeList.AppendChild(xmlEl); //一到这里就出错
xmlEl = xmlDoc.CreateElement("button");
xmlEl.InnerText = "1";
xmlNodeList.AppendChild(xmlEl);
xmlEl = xmlDoc.CreateElement("address");
xmlEl.InnerText = "12345678";
xmlNodeList.AppendChild(xmlEl);
xmlDoc.Save("C:\\YTLcn.xml");