XML 由以下代码创建。
DataSet das = new DataSet();
das = ds.Copy();
das.DataSetName = "Stock";
das.Tables[0].TableName = "Assortment";
das.Tables[0].Columns[1].ColumnName = "Item";
das.Tables[0].Columns[2].ColumnName = "Quantity";
das.Tables[0].Columns[3].ColumnName = "Price";
das.Tables[0].Columns[4].ColumnName = "ValidDate";
das.Tables[0].Columns[5].ColumnName = "Summ";
das.Tables[0].Columns[6].ColumnName = "Manufacturer";
das.Tables[0].Columns[7].ColumnName = "Supplier";
das.WriteXml(LocalPath);
我得到以下xml:
<Stock>
<Assortment>
<ID>1</ID>
<Item>L - тироксин Б/Х таб 100мкг №50</Item>
<Quantity>12</Quantity>
<Price>41496.0000</Price>
<ValidDate>01.01.1999</ValidDate>
<Summ>497952.0000</Summ>
<Manufacturer>Заглушка</Manufacturer>
<Supplier>Заглушка</Supplier>
</Assortment>
<Assortment>
<ID>1242</ID>
<Item>L - тироксин Б/Х таб 100мкг №50</Item>
<Quantity>12</Quantity>
<Price>10.8000</Price>
<ValidDate>01.01.1999</ValidDate>
<Summ>129.6000</Summ>
<Manufacturer>Заглушка</Manufacturer>
<Supplier>Заглушка</Supplier>
</Assortment>
</Stock>
如何将属性添加到根 XML?我想要这样
<Stock Date="11.11.2013">
<Assortment>
<ID>1</ID>
<Item>L - тироксин Б/Х таб 100мкг №50</Item>
<Quantity>12</Quantity>
<Price>41496.0000</Price>
<ValidDate>01.01.1999</ValidDate>
<Summ>497952.0000</Summ>
<Manufacturer>Заглушка</Manufacturer>
<Supplier>Заглушка</Supplier>
</Assortment>
<Assortment>
<ID>1242</ID>
<Item>L - тироксин Б/Х таб 100мкг №50</Item>
<Quantity>12</Quantity>
<Price>10.8000</Price>
<ValidDate>01.01.1999</ValidDate>
<Summ>129.6000</Summ>
<Manufacturer>Заглушка</Manufacturer>
<Supplier>Заглушка</Supplier>
</Assortment>
将日期属性添加到 Stock。因为我想在创建 XML 时读取 Date 。谢谢。