111,092
社区成员




<!--这是英泰力接收器的配置文件 不要删除 否则后果自负-->
<?xml version="1.0" encoding="gb2312"?>
<!--type是设备类型标识 1为按钮开关-->
<YTLcn type="1">
<!--LoopNum回路标识 1是第1个回路-->
<Loop LoopNum="1">
<ID>
<button>1</button>
<address>12345678</address>
</ID>
</Loop>
</YTLcn>
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlEl;
XmlComment comment;
comment=xmlDoc.CreateComment("这是英泰力接收器的配置文件 不要删除 否则后果自负");
XmlDeclaration xmlDec=xmlDoc.CreateXmlDeclaration("1.0", "gb2312", null);
xmlDoc.AppendChild(xmlDec);
xmlDoc.AppendChild(comment);
comment = xmlDoc.CreateComment("type是设备类型标识 1为按钮开关");
xmlDoc.AppendChild(comment);
xmlEl = xmlDoc.CreateElement("YTLcn");
xmlEl.SetAttribute("type", "1");
xmlDoc.AppendChild(xmlEl);
XmlNode xmlNodeList = xmlDoc.SelectSingleNode("YTLcn");
comment = xmlDoc.CreateComment("LoopNum回路标识 1是第1个回路");
xmlDoc.AppendChild(comment);
xmlEl = xmlDoc.CreateElement("Loop");
xmlEl.SetAttribute("LoopNum", "1");
xmlNodeList.AppendChild(xmlEl);
xmlNodeList = xmlDoc.SelectSingleNode("YTLcn/Loop");
xmlEl = xmlDoc.CreateElement("ID");
xmlNodeList.AppendChild(xmlEl);
xmlNodeList = xmlDoc.SelectSingleNode("YTLcn/Loop/ID");
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");
XDocument xd = new XDocument(
new XDeclaration("1.0", "utf-8", "yes"),
new XComment("type是设备类型标识 1为按钮开关"),
new XElement("YTLcn", new XAttribute("type", "1"),
new XComment("LoopNum回路标识 1是第1个回路"),
new XElement("Loop", new XAttribute("LoopNum", "1"),
new XElement("ID",
new XElement("button", "1"),
new XElement("address", "12345678")
)
)
)
);
Console.WriteLine(xd.Declaration);
Console.WriteLine(xd.ToString());