TAILIEUCHUNG - Nested XML

Nested XML As mentioned in Chapter 10, "Using DataSet Objects to Store Data," a DataSet contains two methods that output the contents of the DataRow objects as XML | Nested XML As mentioned in Chapter 10 Using DataSet Objects to Store Data a DataSet contains two methods that output the contents of the DataRow objects as XML GetXml returns the XML representation of the data stored in the DataSet object as a string. WriteXml writes the data from the DataSet object out to an XML file. A DataRelation contains a property named Nested that gets or sets a bool value that indicates whether the DataRelation objects are nested. This is useful when defining hierarchical relationships in XML. Specifically when you set Nested to true the child rows are nested within the parent rows in any XML that you output using the GetXml and WriteXml methods. Similarly you can read the nested rows when calling the ReadXml method of a DataSet to read an XML file. The following example sets a DataRelation object s Nested property to true CustomersOrders .Nested true This is shown in Listing . Notice that this program writes two XML files named and . The contains the default non-nested rows and contains the nested rows after the DataRelation object s Nested property is set to true. illustrates how setting the Nested property of a DataRelation to true causes the the child rows to be nested within the parent rows in the output XML using System using using class NestedXml public static void Main SqlConnection mySqlConnection new SqlConnection server localhost database Northwind uid sa pwd sa SqlCommand mySqlCommand SELECT TOP 2 CustomerlD CompanyName FROM Customers ORDER BY CustomerlD SELECT OrderlD CustomerlD ShipCountry FROM Orders WHERE CustomerlD IN SELECT TOP 2 CustomerlD FROM Customers ORDER BY CustomerlD SqlDataAdapter mySqlDataAdapter new SqlDataAdapter .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.