DataTable.WriteXml 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
DataTable의 현재 내용을 XML로 씁니다.
오버로드
| WriteXml(TextWriter, Boolean) |
지정된 TextWriter를 사용하여 DataTable의 현재 콘텐츠를 XML로 작성합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 |
| WriteXml(TextWriter, XmlWriteMode) |
지정된 DataTable와 TextWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(String, XmlWriteMode) |
지정된 파일과 DataTable를 사용하여 XmlWriteMode에 대해 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(Stream, XmlWriteMode) |
지정된 DataTable를 사용하여 지정된 파일에 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(XmlWriter, Boolean) | |
| WriteXml(XmlWriter, XmlWriteMode) |
지정된 DataTable와 XmlWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(Stream, XmlWriteMode, Boolean) |
지정된 DataTable를 사용하여 지정된 파일에 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(TextWriter, XmlWriteMode, Boolean) |
지정된 DataTable와 TextWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(String, Boolean) |
지정된 파일을 사용하여 DataTable의 현재 내용을 XML로 씁니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 |
| WriteXml(Stream, Boolean) |
지정된 Stream를 사용하여 DataTable의 현재 콘텐츠를 XML로 작성합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 |
| WriteXml(XmlWriter, XmlWriteMode, Boolean) |
지정된 DataTable와 XmlWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(String) |
지정된 파일을 사용하여 DataTable의 현재 내용을 XML로 씁니다. |
| WriteXml(TextWriter) |
지정된 TextWriter를 사용하여 DataTable의 현재 콘텐츠를 XML로 작성합니다. |
| WriteXml(Stream) | |
| WriteXml(String, XmlWriteMode, Boolean) |
지정된 파일과 DataTable를 사용하여 XmlWriteMode에 대해 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 |
| WriteXml(XmlWriter) |
예제
다음 콘솔 애플리케이션 두 개를 만듭니다 DataTable 인스턴스, 각 추가 DataSet를 만듭니다를 DataRelation 두 관련 테이블을 선택한 다음 사용 하 여는 WriteXml 는부모테이블내에포함된데이터를쓸메서드TextWriter. 이 예제에서는 매개 변수를 각 값으로 writeHierarchy 설정할 때의 동작을 보여 줍니다.
참고
이 예제에서는 오버로드된 WriteXml 버전 중 하나를 사용하는 방법을 보여줍니다. 사용할 수 있는 다른 예제를 오버 로드 개별 항목을 참조 하십시오.
static void Main()
{
DataSet ds = new DataSet();
DataTable customerTable = GetCustomers();
DataTable orderTable = GetOrders();
ds.Tables.Add(customerTable);
ds.Tables.Add(orderTable);
ds.Relations.Add("CustomerOrder",
new DataColumn[] { customerTable.Columns[0] },
new DataColumn[] { orderTable.Columns[1] }, true);
System.IO.StringWriter writer = new System.IO.StringWriter();
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, false);
PrintOutput(writer, "Customer table, without hierarchy");
writer = new System.IO.StringWriter();
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, true);
PrintOutput(writer, "Customer table, with hierarchy");
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
private static DataTable GetCustomers()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create two columns, ID and Name.
DataColumn idColumn = table.Columns.Add("ID", typeof(System.Int32));
table.Columns.Add("Name", typeof(System.String));
// Set the ID column as the primary key column.
table.PrimaryKey = new DataColumn[] { idColumn };
table.Rows.Add(new object[] { 1, "Mary" });
table.Rows.Add(new object[] { 2, "Andy" });
table.Rows.Add(new object[] { 3, "Peter" });
table.Rows.Add(new object[] { 4, "Russ" });
table.AcceptChanges();
return table;
}
private static DataTable GetOrders()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create three columns; OrderID, CustomerID, and OrderDate.
table.Columns.Add(new DataColumn("OrderID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("CustomerID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("OrderDate", typeof(System.DateTime)));
// Set the OrderID column as the primary key column.
table.PrimaryKey = new DataColumn[] { table.Columns[0] };
table.Rows.Add(new object[] { 1, 1, "12/2/2003" });
table.Rows.Add(new object[] { 2, 1, "1/3/2004" });
table.Rows.Add(new object[] { 3, 2, "11/13/2004" });
table.Rows.Add(new object[] { 4, 3, "5/16/2004" });
table.Rows.Add(new object[] { 5, 3, "5/22/2004" });
table.Rows.Add(new object[] { 6, 4, "6/15/2004" });
table.AcceptChanges();
return table;
}
private static void PrintOutput(System.IO.TextWriter writer, string caption)
{
Console.WriteLine("==============================");
Console.WriteLine(caption);
Console.WriteLine("==============================");
Console.WriteLine(writer.ToString());
}
Sub Main()
Dim ds As New DataSet
Dim customerTable As DataTable = GetCustomers()
Dim orderTable As DataTable = GetOrders()
ds.Tables.Add(customerTable)
ds.Tables.Add(orderTable)
ds.Relations.Add("CustomerOrder", _
New DataColumn() {customerTable.Columns(0)}, _
New DataColumn() {orderTable.Columns(1)}, True)
Dim writer As New System.IO.StringWriter
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, False)
PrintOutput(writer, "Customer table, without hierarchy")
writer = New System.IO.StringWriter
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, True)
PrintOutput(writer, "Customer table, with hierarchy")
Console.WriteLine("Press any key to continue.")
Console.ReadKey()
End Sub
Private Function GetOrders() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create three columns, OrderID, CustomerID, and OrderDate.
table.Columns.Add(New DataColumn("OrderID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("CustomerID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("OrderDate", GetType(System.DateTime)))
' Set the OrderID column as the primary key column.
table.PrimaryKey = New DataColumn() {table.Columns(0)}
table.Rows.Add(New Object() {1, 1, #12/2/2003#})
table.Rows.Add(New Object() {2, 1, #1/3/2004#})
table.Rows.Add(New Object() {3, 2, #11/13/2004#})
table.Rows.Add(New Object() {4, 3, #5/16/2004#})
table.Rows.Add(New Object() {5, 3, #5/22/2004#})
table.Rows.Add(New Object() {6, 4, #6/15/2004#})
table.AcceptChanges()
Return table
End Function
Private Function GetCustomers() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", _
GetType(System.Int32))
table.Columns.Add("Name", GetType(System.String))
' Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
table.Rows.Add(New Object() {1, "Mary"})
table.Rows.Add(New Object() {2, "Andy"})
table.Rows.Add(New Object() {3, "Peter"})
table.Rows.Add(New Object() {4, "Russ"})
table.AcceptChanges()
Return table
End Function
Private Sub PrintOutput( _
ByVal writer As System.IO.TextWriter, ByVal caption As String)
Console.WriteLine("==============================")
Console.WriteLine(caption)
Console.WriteLine("==============================")
Console.WriteLine(writer.ToString())
End Sub
이 예제에서는 콘솔 창에 다음 출력을 표시합니다.
==============================
Customer table, without hierarchy
==============================
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema
" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Table1" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>
<Table1>
<ID>1</ID>
<Name>Mary</Name>
</Table1>
<Table1>
<ID>2</ID>
<Name>Andy</Name>
</Table1>
<Table1>
<ID>3</ID>
<Name>Peter</Name>
</Table1>
<Table1>
<ID>4</ID>
<Name>Russ</Name>
</Table1>
</NewDataSet>
==============================
Customer table, with hierarchy
==============================
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema
" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderID" type="xs:int" />
<xs:element name="CustomerID" type="xs:int" minOccurs="0" />
<xs:element name="OrderDate" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Table1" />
<xs:field xpath="ID" />
</xs:unique>
<xs:unique name="Table2_Constraint1" msdata:ConstraintName="Constraint1" m
sdata:PrimaryKey="true">
<xs:selector xpath=".//Table2" />
<xs:field xpath="OrderID" />
</xs:unique>
<xs:keyref name="CustomerOrder" refer="Constraint1">
<xs:selector xpath=".//Table2" />
<xs:field xpath="CustomerID" />
</xs:keyref>
</xs:element>
</xs:schema>
<Table1>
<ID>1</ID>
<Name>Mary</Name>
</Table1>
<Table1>
<ID>2</ID>
<Name>Andy</Name>
</Table1>
<Table1>
<ID>3</ID>
<Name>Peter</Name>
</Table1>
<Table1>
<ID>4</ID>
<Name>Russ</Name>
</Table1>
<Table2>
<OrderID>1</OrderID>
<CustomerID>1</CustomerID>
<OrderDate>2003-12-02T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>2</OrderID>
<CustomerID>1</CustomerID>
<OrderDate>2004-01-03T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>3</OrderID>
<CustomerID>2</CustomerID>
<OrderDate>2004-11-13T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>4</OrderID>
<CustomerID>3</CustomerID>
<OrderDate>2004-05-16T00:00:00.0000000-07:00</OrderDate>
</Table2>
<Table2>
<OrderID>5</OrderID>
<CustomerID>3</CustomerID>
<OrderDate>2004-05-22T00:00:00.0000000-07:00</OrderDate>
</Table2>
<Table2>
<OrderID>6</OrderID>
<CustomerID>4</CustomerID>
<OrderDate>2004-06-15T00:00:00.0000000-07:00</OrderDate>
</Table2>
</NewDataSet>
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
WriteXml(TextWriter, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 TextWriter를 사용하여 DataTable의 현재 콘텐츠를 XML로 작성합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::IO::TextWriter ^ writer, bool writeHierarchy);
public void WriteXml (System.IO.TextWriter? writer, bool writeHierarchy);
public void WriteXml (System.IO.TextWriter writer, bool writeHierarchy);
member this.WriteXml : System.IO.TextWriter * bool -> unit
Public Sub WriteXml (writer As TextWriter, writeHierarchy As Boolean)
매개 변수
- writer
- TextWriter
콘텐츠를 쓰는 데 사용할 TextWriter입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
예제
다음 콘솔 애플리케이션 두 개를 만듭니다 DataTable 인스턴스, 각 추가 DataSet를 만듭니다를 DataRelation 두 관련 테이블을 선택한 다음 사용 하 여는 WriteXml 는부모테이블내에포함된데이터를쓸메서드TextWriter. 이 예제에서는 매개 변수를 로 설정할 때의 동작을 writeHierarchy 보여 줍니다 true.
static void Main()
{
DataSet ds = new DataSet();
DataTable customerTable = GetCustomers();
DataTable orderTable = GetOrders();
ds.Tables.Add(customerTable);
ds.Tables.Add(orderTable);
ds.Relations.Add("CustomerOrder",
new DataColumn[] { customerTable.Columns[0] },
new DataColumn[] { orderTable.Columns[1] }, true);
System.IO.StringWriter writer = new System.IO.StringWriter();
customerTable.WriteXml(writer, true);
PrintOutput(writer, "Customer table, with hierarchy");
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
private static DataTable GetCustomers()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create two columns, ID and Name.
DataColumn idColumn = table.Columns.Add("ID", typeof(System.Int32));
table.Columns.Add("Name", typeof(System.String));
// Set the ID column as the primary key column.
table.PrimaryKey = new DataColumn[] { idColumn };
table.Rows.Add(new object[] { 1, "Mary" });
table.Rows.Add(new object[] { 2, "Andy" });
table.Rows.Add(new object[] { 3, "Peter" });
table.Rows.Add(new object[] { 4, "Russ" });
table.AcceptChanges();
return table;
}
private static DataTable GetOrders()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create three columns; OrderID, CustomerID, and OrderDate.
table.Columns.Add(new DataColumn("OrderID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("CustomerID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("OrderDate", typeof(System.DateTime)));
// Set the OrderID column as the primary key column.
table.PrimaryKey = new DataColumn[] { table.Columns[0] };
table.Rows.Add(new object[] { 1, 1, "12/2/2003" });
table.Rows.Add(new object[] { 2, 1, "1/3/2004" });
table.Rows.Add(new object[] { 3, 2, "11/13/2004" });
table.Rows.Add(new object[] { 4, 3, "5/16/2004" });
table.Rows.Add(new object[] { 5, 3, "5/22/2004" });
table.Rows.Add(new object[] { 6, 4, "6/15/2004" });
table.AcceptChanges();
return table;
}
private static void PrintOutput(System.IO.TextWriter stream,
string caption)
{
Console.WriteLine("==============================");
Console.WriteLine(caption);
Console.WriteLine("==============================");
Console.WriteLine(stream.ToString());
}
Sub Main()
Dim ds As New DataSet
Dim customerTable As DataTable = GetCustomers()
Dim orderTable As DataTable = GetOrders()
ds.Tables.Add(customerTable)
ds.Tables.Add(orderTable)
ds.Relations.Add("CustomerOrder", _
New DataColumn() {customerTable.Columns(0)}, _
New DataColumn() {orderTable.Columns(1)}, True)
Dim writer As New System.IO.StringWriter
customerTable.WriteXml(writer, True)
PrintOutput(writer, "Customer table, with hierarchy")
Console.WriteLine("Press any key to continue.")
Console.ReadKey()
End Sub
Private Function GetOrders() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create three columns, OrderID, CustomerID, and OrderDate.
table.Columns.Add(New DataColumn("OrderID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("CustomerID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("OrderDate", GetType(System.DateTime)))
' Set the OrderID column as the primary key column.
table.PrimaryKey = New DataColumn() {table.Columns(0)}
table.Rows.Add(New Object() {1, 1, #12/2/2003#})
table.Rows.Add(New Object() {2, 1, #1/3/2004#})
table.Rows.Add(New Object() {3, 2, #11/13/2004#})
table.Rows.Add(New Object() {4, 3, #5/16/2004#})
table.Rows.Add(New Object() {5, 3, #5/22/2004#})
table.Rows.Add(New Object() {6, 4, #6/15/2004#})
table.AcceptChanges()
Return table
End Function
Private Function GetCustomers() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", _
GetType(System.Int32))
table.Columns.Add("Name", GetType(System.String))
' Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
table.Rows.Add(New Object() {1, "Mary"})
table.Rows.Add(New Object() {2, "Andy"})
table.Rows.Add(New Object() {3, "Peter"})
table.Rows.Add(New Object() {4, "Russ"})
table.AcceptChanges()
Return table
End Function
Private Sub PrintOutput( _
ByVal stream As System.IO.TextWriter, ByVal caption As String)
Console.WriteLine("==============================")
Console.WriteLine(caption)
Console.WriteLine("==============================")
Console.WriteLine(stream.ToString())
End Sub
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 테이블 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(TextWriter, XmlWriteMode)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable와 TextWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다.
public:
void WriteXml(System::IO::TextWriter ^ writer, System::Data::XmlWriteMode mode);
public void WriteXml (System.IO.TextWriter? writer, System.Data.XmlWriteMode mode);
public void WriteXml (System.IO.TextWriter writer, System.Data.XmlWriteMode mode);
member this.WriteXml : System.IO.TextWriter * System.Data.XmlWriteMode -> unit
Public Sub WriteXml (writer As TextWriter, mode As XmlWriteMode)
매개 변수
- writer
- TextWriter
문서를 쓰는 데 사용되는 TextWriter입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(String, XmlWriteMode)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 파일과 DataTable를 사용하여 XmlWriteMode에 대해 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다.
public:
void WriteXml(System::String ^ fileName, System::Data::XmlWriteMode mode);
public void WriteXml (string fileName, System.Data.XmlWriteMode mode);
member this.WriteXml : string * System.Data.XmlWriteMode -> unit
Public Sub WriteXml (fileName As String, mode As XmlWriteMode)
매개 변수
- fileName
- String
데이터가 기록될 파일의 이름입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(Stream, XmlWriteMode)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable를 사용하여 지정된 파일에 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다.
public:
void WriteXml(System::IO::Stream ^ stream, System::Data::XmlWriteMode mode);
public void WriteXml (System.IO.Stream? stream, System.Data.XmlWriteMode mode);
public void WriteXml (System.IO.Stream stream, System.Data.XmlWriteMode mode);
member this.WriteXml : System.IO.Stream * System.Data.XmlWriteMode -> unit
Public Sub WriteXml (stream As Stream, mode As XmlWriteMode)
매개 변수
- stream
- Stream
데이터가 기록될 스트림입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(XmlWriter, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
public:
void WriteXml(System::Xml::XmlWriter ^ writer, bool writeHierarchy);
public void WriteXml (System.Xml.XmlWriter? writer, bool writeHierarchy);
public void WriteXml (System.Xml.XmlWriter writer, bool writeHierarchy);
member this.WriteXml : System.Xml.XmlWriter * bool -> unit
Public Sub WriteXml (writer As XmlWriter, writeHierarchy As Boolean)
매개 변수
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 해당 전체 하위 테이블 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(XmlWriter, XmlWriteMode)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable와 XmlWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다.
public:
void WriteXml(System::Xml::XmlWriter ^ writer, System::Data::XmlWriteMode mode);
public void WriteXml (System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode);
public void WriteXml (System.Xml.XmlWriter writer, System.Data.XmlWriteMode mode);
member this.WriteXml : System.Xml.XmlWriter * System.Data.XmlWriteMode -> unit
Public Sub WriteXml (writer As XmlWriter, mode As XmlWriteMode)
매개 변수
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(Stream, XmlWriteMode, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable를 사용하여 지정된 파일에 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::IO::Stream ^ stream, System::Data::XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.IO.Stream? stream, System.Data.XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.IO.Stream stream, System.Data.XmlWriteMode mode, bool writeHierarchy);
member this.WriteXml : System.IO.Stream * System.Data.XmlWriteMode * bool -> unit
Public Sub WriteXml (stream As Stream, mode As XmlWriteMode, writeHierarchy As Boolean)
매개 변수
- stream
- Stream
데이터가 기록될 스트림입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대한 데이터만 저장합니다. 메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 테이블 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(TextWriter, XmlWriteMode, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable와 TextWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::IO::TextWriter ^ writer, System::Data::XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.IO.TextWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.IO.TextWriter writer, System.Data.XmlWriteMode mode, bool writeHierarchy);
member this.WriteXml : System.IO.TextWriter * System.Data.XmlWriteMode * bool -> unit
Public Sub WriteXml (writer As TextWriter, mode As XmlWriteMode, writeHierarchy As Boolean)
매개 변수
- writer
- TextWriter
문서를 쓰는 데 사용되는 TextWriter입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
예제
다음 콘솔 애플리케이션 두 개를 만듭니다 DataTable 인스턴스, 각 추가 DataSet를 만듭니다를 DataRelation 두 관련 테이블을 선택한 다음 사용 하 여는 WriteXml 는부모테이블내에포함된데이터를쓸메서드TextWriter. 이 예제에서는 매개 변수를 각 값으로 writeHierarchy 설정할 때의 동작을 보여 줍니다.
static void Main()
{
DataSet ds = new DataSet();
DataTable customerTable = GetCustomers();
DataTable orderTable = GetOrders();
ds.Tables.Add(customerTable);
ds.Tables.Add(orderTable);
ds.Relations.Add("CustomerOrder",
new DataColumn[] { customerTable.Columns[0] },
new DataColumn[] { orderTable.Columns[1] }, true);
System.IO.StringWriter writer = new System.IO.StringWriter();
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, false);
PrintOutput(writer, "Customer table, without hierarchy");
writer = new System.IO.StringWriter();
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, true);
PrintOutput(writer, "Customer table, with hierarchy");
Console.WriteLine("Press any key to continue.");
Console.ReadKey();
}
private static DataTable GetCustomers()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create two columns, ID and Name.
DataColumn idColumn = table.Columns.Add("ID", typeof(System.Int32));
table.Columns.Add("Name", typeof(System.String));
// Set the ID column as the primary key column.
table.PrimaryKey = new DataColumn[] { idColumn };
table.Rows.Add(new object[] { 1, "Mary" });
table.Rows.Add(new object[] { 2, "Andy" });
table.Rows.Add(new object[] { 3, "Peter" });
table.Rows.Add(new object[] { 4, "Russ" });
table.AcceptChanges();
return table;
}
private static DataTable GetOrders()
{
// Create sample Customers table, in order
// to demonstrate the behavior of the DataTableReader.
DataTable table = new DataTable();
// Create three columns; OrderID, CustomerID, and OrderDate.
table.Columns.Add(new DataColumn("OrderID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("CustomerID", typeof(System.Int32)));
table.Columns.Add(new DataColumn("OrderDate", typeof(System.DateTime)));
// Set the OrderID column as the primary key column.
table.PrimaryKey = new DataColumn[] { table.Columns[0] };
table.Rows.Add(new object[] { 1, 1, "12/2/2003" });
table.Rows.Add(new object[] { 2, 1, "1/3/2004" });
table.Rows.Add(new object[] { 3, 2, "11/13/2004" });
table.Rows.Add(new object[] { 4, 3, "5/16/2004" });
table.Rows.Add(new object[] { 5, 3, "5/22/2004" });
table.Rows.Add(new object[] { 6, 4, "6/15/2004" });
table.AcceptChanges();
return table;
}
private static void PrintOutput(System.IO.TextWriter writer,
string caption)
{
Console.WriteLine("==============================");
Console.WriteLine(caption);
Console.WriteLine("==============================");
Console.WriteLine(writer.ToString());
}
Sub Main()
Dim ds As New DataSet
Dim customerTable As DataTable = GetCustomers()
Dim orderTable As DataTable = GetOrders()
ds.Tables.Add(customerTable)
ds.Tables.Add(orderTable)
ds.Relations.Add("CustomerOrder", _
New DataColumn() {customerTable.Columns(0)}, _
New DataColumn() {orderTable.Columns(1)}, True)
Dim writer As New System.IO.StringWriter
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, False)
PrintOutput(writer, "Customer table, without hierarchy")
writer = New System.IO.StringWriter
customerTable.WriteXml(writer, XmlWriteMode.WriteSchema, True)
PrintOutput(writer, "Customer table, with hierarchy")
Console.WriteLine("Press any key to continue.")
Console.ReadKey()
End Sub
Private Function GetOrders() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create three columns, OrderID, CustomerID, and OrderDate.
table.Columns.Add(New DataColumn("OrderID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("CustomerID", GetType(System.Int32)))
table.Columns.Add(New DataColumn("OrderDate", GetType(System.DateTime)))
' Set the OrderID column as the primary key column.
table.PrimaryKey = New DataColumn() {table.Columns(0)}
table.Rows.Add(New Object() {1, 1, #12/2/2003#})
table.Rows.Add(New Object() {2, 1, #1/3/2004#})
table.Rows.Add(New Object() {3, 2, #11/13/2004#})
table.Rows.Add(New Object() {4, 3, #5/16/2004#})
table.Rows.Add(New Object() {5, 3, #5/22/2004#})
table.Rows.Add(New Object() {6, 4, #6/15/2004#})
table.AcceptChanges()
Return table
End Function
Private Function GetCustomers() As DataTable
' Create sample Customers table, in order
' to demonstrate the behavior of the DataTableReader.
Dim table As New DataTable
' Create two columns, ID and Name.
Dim idColumn As DataColumn = table.Columns.Add("ID", _
GetType(System.Int32))
table.Columns.Add("Name", GetType(System.String))
' Set the ID column as the primary key column.
table.PrimaryKey = New DataColumn() {idColumn}
table.Rows.Add(New Object() {1, "Mary"})
table.Rows.Add(New Object() {2, "Andy"})
table.Rows.Add(New Object() {3, "Peter"})
table.Rows.Add(New Object() {4, "Russ"})
table.AcceptChanges()
Return table
End Function
Private Sub PrintOutput( _
ByVal writer As System.IO.TextWriter, ByVal caption As String)
Console.WriteLine("==============================")
Console.WriteLine(caption)
Console.WriteLine("==============================")
Console.WriteLine(writer.ToString())
End Sub
이 예제에서는 콘솔 창에 다음 출력을 표시합니다.
==============================
Customer table, without hierarchy
==============================
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema
" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Table1" />
<xs:field xpath="ID" />
</xs:unique>
</xs:element>
</xs:schema>
<Table1>
<ID>1</ID>
<Name>Mary</Name>
</Table1>
<Table1>
<ID>2</ID>
<Name>Andy</Name>
</Table1>
<Table1>
<ID>3</ID>
<Name>Peter</Name>
</Table1>
<Table1>
<ID>4</ID>
<Name>Russ</Name>
</Table1>
</NewDataSet>
==============================
Customer table, with hierarchy
==============================
<NewDataSet>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema
" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:MainDataTable="Table1">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table1">
<xs:complexType>
<xs:sequence>
<xs:element name="ID" type="xs:int" />
<xs:element name="Name" type="xs:string" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Table2">
<xs:complexType>
<xs:sequence>
<xs:element name="OrderID" type="xs:int" />
<xs:element name="CustomerID" type="xs:int" minOccurs="0" />
<xs:element name="OrderDate" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="Constraint1" msdata:PrimaryKey="true">
<xs:selector xpath=".//Table1" />
<xs:field xpath="ID" />
</xs:unique>
<xs:unique name="Table2_Constraint1" msdata:ConstraintName="Constraint1" m
sdata:PrimaryKey="true">
<xs:selector xpath=".//Table2" />
<xs:field xpath="OrderID" />
</xs:unique>
<xs:keyref name="CustomerOrder" refer="Constraint1">
<xs:selector xpath=".//Table2" />
<xs:field xpath="CustomerID" />
</xs:keyref>
</xs:element>
</xs:schema>
<Table1>
<ID>1</ID>
<Name>Mary</Name>
</Table1>
<Table1>
<ID>2</ID>
<Name>Andy</Name>
</Table1>
<Table1>
<ID>3</ID>
<Name>Peter</Name>
</Table1>
<Table1>
<ID>4</ID>
<Name>Russ</Name>
</Table1>
<Table2>
<OrderID>1</OrderID>
<CustomerID>1</CustomerID>
<OrderDate>2003-12-02T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>2</OrderID>
<CustomerID>1</CustomerID>
<OrderDate>2004-01-03T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>3</OrderID>
<CustomerID>2</CustomerID>
<OrderDate>2004-11-13T00:00:00.0000000-08:00</OrderDate>
</Table2>
<Table2>
<OrderID>4</OrderID>
<CustomerID>3</CustomerID>
<OrderDate>2004-05-16T00:00:00.0000000-07:00</OrderDate>
</Table2>
<Table2>
<OrderID>5</OrderID>
<CustomerID>3</CustomerID>
<OrderDate>2004-05-22T00:00:00.0000000-07:00</OrderDate>
</Table2>
<Table2>
<OrderID>6</OrderID>
<CustomerID>4</CustomerID>
<OrderDate>2004-06-15T00:00:00.0000000-07:00</OrderDate>
</Table2>
</NewDataSet>
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대한 데이터만 저장합니다. 메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면, 메서드는 WriteXmlSchema 스키마만 씁니다. 데이터와 스키마를 모두 쓰려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 테이블 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(String, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 파일을 사용하여 DataTable의 현재 내용을 XML로 씁니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::String ^ fileName, bool writeHierarchy);
public void WriteXml (string fileName, bool writeHierarchy);
member this.WriteXml : string * bool -> unit
Public Sub WriteXml (fileName As String, writeHierarchy As Boolean)
매개 변수
- fileName
- String
XML 데이터를 기록할 파일입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(Stream, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
public:
void WriteXml(System::IO::Stream ^ stream, bool writeHierarchy);
public void WriteXml (System.IO.Stream? stream, bool writeHierarchy);
public void WriteXml (System.IO.Stream stream, bool writeHierarchy);
member this.WriteXml : System.IO.Stream * bool -> unit
Public Sub WriteXml (stream As Stream, writeHierarchy As Boolean)
매개 변수
- stream
- Stream
데이터가 기록될 스트림입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드를 WriteXmlSchema 사용하여 에 대한 스키마를 DataTable XML 문서에 씁니다. 스키마에는 테이블, 관계 및 제약 조건 정의가 포함됩니다.
XML 스키마는 XSD 표준을 사용하여 작성됩니다.
XML 문서에 데이터를 쓰려면 메서드를 WriteXml 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(XmlWriter, XmlWriteMode, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 DataTable와 XmlWriter를 사용하여 XmlWriteMode의 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::Xml::XmlWriter ^ writer, System::Data::XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.Xml.XmlWriter? writer, System.Data.XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (System.Xml.XmlWriter writer, System.Data.XmlWriteMode mode, bool writeHierarchy);
member this.WriteXml : System.Xml.XmlWriter * System.Data.XmlWriteMode * bool -> unit
Public Sub WriteXml (writer As XmlWriter, mode As XmlWriteMode, writeHierarchy As Boolean)
매개 변수
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 전체 하위 테이블 관련 테이블에 대한 데이터를 쓰려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(String)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 파일을 사용하여 DataTable의 현재 내용을 XML로 씁니다.
public:
void WriteXml(System::String ^ fileName);
public void WriteXml (string fileName);
member this.WriteXml : string -> unit
Public Sub WriteXml (fileName As String)
매개 변수
- fileName
- String
XML 데이터를 기록할 파일입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(TextWriter)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 TextWriter를 사용하여 DataTable의 현재 콘텐츠를 XML로 작성합니다.
public:
void WriteXml(System::IO::TextWriter ^ writer);
public void WriteXml (System.IO.TextWriter? writer);
public void WriteXml (System.IO.TextWriter writer);
member this.WriteXml : System.IO.TextWriter -> unit
Public Sub WriteXml (writer As TextWriter)
매개 변수
- writer
- TextWriter
콘텐츠를 쓰는 데 사용할 TextWriter입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(Stream)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
public:
void WriteXml(System::IO::Stream ^ stream);
public void WriteXml (System.IO.Stream? stream);
public void WriteXml (System.IO.Stream stream);
member this.WriteXml : System.IO.Stream -> unit
Public Sub WriteXml (stream As Stream)
매개 변수
- stream
- Stream
데이터가 기록될 스트림입니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(String, XmlWriteMode, Boolean)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
지정된 파일과 DataTable를 사용하여 XmlWriteMode에 대해 현재 데이터를 쓰고 선택적으로 스키마를 씁니다. 스키마를 쓰려면 mode 매개 변수 값을 WriteSchema로 설정합니다. 테이블과 모든 하위 항목의 데이터를 저장하려면 writeHierarchy 매개 변수를 true로 설정합니다.
public:
void WriteXml(System::String ^ fileName, System::Data::XmlWriteMode mode, bool writeHierarchy);
public void WriteXml (string fileName, System.Data.XmlWriteMode mode, bool writeHierarchy);
member this.WriteXml : string * System.Data.XmlWriteMode * bool -> unit
Public Sub WriteXml (fileName As String, mode As XmlWriteMode, writeHierarchy As Boolean)
매개 변수
- fileName
- String
데이터가 기록될 파일의 이름입니다.
- mode
- XmlWriteMode
XmlWriteMode 값 중 하나입니다.
- writeHierarchy
- Boolean
true이면 현재 테이블과 모든 하위 항목의 내용을 씁니다.
false(기본값)이면 현재 테이블의 데이터만 씁니다.
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 저장합니다. 현재 테이블 및 모든 스키마 WriteXml 에 대한 데이터를 저장하려는 경우 메서드는 데이터만 작성하거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 쓰는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
일반적으로 메서드는 WriteXml 현재 테이블에 대해서만 데이터를 씁니다. 현재 테이블 및 모든 하위 테이블 관련 테이블에 대한 데이터를 작성하려면 매개 변수가 로 설정된 메서드를 writeHierarchy 호출합니다 true.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.
추가 정보
적용 대상
WriteXml(XmlWriter)
- Source:
- DataTable.cs
- Source:
- DataTable.cs
- Source:
- DataTable.cs
public:
void WriteXml(System::Xml::XmlWriter ^ writer);
public void WriteXml (System.Xml.XmlWriter? writer);
public void WriteXml (System.Xml.XmlWriter writer);
member this.WriteXml : System.Xml.XmlWriter -> unit
Public Sub WriteXml (writer As XmlWriter)
매개 변수
설명
메서드는 WriteXml 데이터만 쓰거나 에서 XML 문서로 데이터와 스키마 DataTable 를 모두 작성하는 방법을 제공하는 반면 WriteXmlSchema 메서드는 스키마만 씁니다. 데이터와 스키마를 모두 작성하려면 매개 변수를 포함하는 XmlWriteMode 오버로드 중 하나를 사용하고 해당 값을 로 WriteSchema설정합니다.
및 ReadXmlSchema 메서드에 대해 ReadXml 각각 동일합니다. XML 데이터 또는 스키마와 데이터를 모두 로 DataTable읽으려면 메서드를 ReadXml 사용합니다. 스키마만 읽으려면 메서드를 ReadXmlSchema 사용합니다.
참고
InvalidOperationException 경우의 열 형식에 throw 됩니다 합니다 DataRow 에서 읽거나 쓴 구현 되 IDynamicMetaObjectProvider 구현 하지 않습니다 IXmlSerializable합니다.