majkinetor
Programmer
This is the sample code I am using to create nes\ted xml.
I get this XML at output:
I want to get it without line colored in blue.
How can I achieve that so that XMLExport "knows" that I don't want them. Can I somehow mark columns from dataset that I use for relation so that they don't appear double in XML Export.
Thx in advance
Code:
static void Main(string[] args)
{
string myConString = "Initial Catalog=Northwind;Data Source=10.32.34.180;Integrated Security=SSPI;";
SqlConnection nwindConn = new SqlConnection(myConString);
SqlDataAdapter custDA = new SqlDataAdapter("SELECT CustomerID, CompanyName FROM Customers", nwindConn);
SqlDataAdapter orderDA = new SqlDataAdapter("SELECT OrderID, CustomerID, OrderDate FROM Orders", nwindConn);
SqlDataAdapter detDA = new SqlDataAdapter("SELECT * FROM [Order Details]", nwindConn);
nwindConn.Open();
DataSet custDS = new DataSet("CustomerOrders");
custDA.Fill(custDS, "Customers");
orderDA.Fill(custDS, "Orders");
detDA.Fill(custDS, "OrderDetails");
nwindConn.Close();
DataRelation rel = custDS.Relations.Add("CustOrders",
custDS.Tables["Customers"].Columns["CustomerID"],
custDS.Tables["Orders"].Columns["CustomerID"]);
DataRelation rel2 = custDS.Relations.Add("Details",
custDS.Tables["Orders"].Columns["OrderID"],
custDS.Tables["OrderDetails"].Columns["OrderID"]);
rel.Nested = rel2.Nested = true;
custDS.WriteXml("c:\\_nested.xml");
}
}
I get this XML at output:
Code:
CustomerOrders>
<Customers>
<CustomerID>ALFKI</CustomerID>
<CompanyName>Alfreds Futterkiste</CompanyName>
<Orders>
[blue] <OrderID>10643</OrderID>[/blue]
<CustomerID>ALFKI</CustomerID>
<OrderDate>1997-08-25T00:00:00.0000000+02:00</OrderDate>
<OrderDetails>
<OrderID>10643</OrderID>
<ProductID>28</ProductID>
<UnitPrice>45.6000</UnitPrice>
<Quantity>15</Quantity>
<Discount>0.25</Discount>
</OrderDetails>
<OrderDetails>
<OrderID>10643</OrderID>
<ProductID>39</ProductID>
.......
.......
I want to get it without line colored in blue.
How can I achieve that so that XMLExport "knows" that I don't want them. Can I somehow mark columns from dataset that I use for relation so that they don't appear double in XML Export.
Thx in advance