Я хочу вставить элементы итерации (Сигнал) в соответствии с моим требованием, как показано ниже: вывод XML.
<?xml version="1.0" encoding="UTF-8"?>
<WIUConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Timestamp>2006-05-04T18:13:51.0Z</Timestamp>
<WIUAddress>WIUAddress0</WIUAddress>
<WIUName>WIUName0</WIUName>
<BeaconFlag>Y</BeaconFlag>
<EncryptedHMACkey>30</EncryptedHMACkey>
<DeviceStatusConfigVersion>DeviceStatusConfigVersion0</DeviceStatusConfigVersion>
<Signal>
<SiteDeviceId>SiteDeviceId0</SiteDeviceId>
<SiteName>SiteName0</SiteName>
<TrackName>TrackName0</TrackName>
</Signal>
<Signal>
<SiteDeviceId>SiteDeviceId1</SiteDeviceId>
<SiteName>SiteName1</SiteName>
<TrackName>TrackName1</TrackName>
</Signal>
<Signal>
.
.
.
</Signal>
</WIUConfig>
как я могу реализовать эту концепцию итерации, используя C # .net LINQ to XML
Вот мой код:
XDocument xdco = new XDocument(
new XDeclaration("1.0", "utf-8", "Yes"),
new XComment("WIU Configurations"),
new XElement("WIUConfig",
new XElement("Timestamp", datetime),
new XElement("WIUAddress", ds.Tables[0].Rows[0][0].ToString()),
new XElement("WIUName", ds.Tables[0].Rows[0][1].ToString()),
new XElement("BeaconFlag", "Y"),
new XElement("EncryptedHMACkey", ds1.Tables[0].Rows[0][0].ToString()),
new XElement("DeviceStatusConfigSCAC", ds.Tables[0].Rows[0][0].ToString()),
new XElement("DeviceStatusConfigTableId", ds.Tables[0].Rows[0][0].ToString()),
new XElement("DeviceStatusConfigVersion", ds.Tables[0].Rows[0][0].ToString()),
**????????(iteration code) **
));
xdco.Save(OutPath);
код сверху, как вставить элемент итерации с XML-файлом?