using System;
using System.Data;
class Program
{
static void Main()
{
DataTable table1
= new DataTable("customer");
table1.Columns.Add("name");
table1.Columns.Add("id");
table1.Rows.Add("onj1", 1);
table1.Rows.Add("onj2", 2);
DataTable table2
= new DataTable("sale");
table2.Columns.Add("id");
table2.Columns.Add("goods");
table2.Rows.Add(1, "볼펜");
table2.Rows.Add(2, "연필");
DataSet set =
new DataSet("office");
set.Tables.Add(table1);
set.Tables.Add(table2);
// XML형태로
출력
Console.WriteLine(set.GetXml());
}
}
[결과]
<office>
<customer>
<name>onj1</name>
<id>1</id>
</customer>
<customer>
<name>onj2</name>
<id>2</id>
</customer>
<sale>
<id>1</id>
<goods>볼펜</goods>
</sale>
<sale>
<id>2</id>
<goods>연필</goods>
</sale>
</office>
댓글 없음:
댓글 쓰기