Does not work. I add the data to the textbox. I press the button. Data is saved. I open xml, and in it only the last value. Where is the error, tell me?
private void button12_Click(object sender, EventArgs e) // НЕИЗВЕСТНО РАБОТАЕТ { // таблица DataSet ds = new DataSet(); DataTable dt = new DataTable(); dt.TableName = "SearchWords"; // название таблицы dt.Columns.Add("word"); // название колонки ds.Tables.Add(dt); // добавляем строки DataRow row = ds.Tables["SearchWords"].NewRow(); row["word"] = textBox4.Text; ds.Tables["SearchWords"].Rows.Add(row); // сохраняем ds.WriteXml("D:\\Words.xml"); } The xml only needs one column with the word data entered.
<?xml version="1.0" standalone="yes"?> <NewDataSet> <SearchWords> <word>111111111</word> </SearchWords> </NewDataSet> And tell me how to make xml like this:
<NewDataSet> <SearchWords> <word>888888</word> <word>22</word> <word>11111</word> </SearchWords> </NewDataSet> And with the current code it turns out like this (i.e. a lot of extra tags):
<?xml version="1.0" standalone="yes"?> <NewDataSet> <SearchWords> <word>888888</word> </SearchWords> <SearchWords> <word>22</word> </SearchWords> <SearchWords> <word>11111</word> </SearchWords> </NewDataSet>