Following code is C#.
Load the data into the DataSet.
customersAdapter.Fill(dataSet1, "Customers");
ordersAdapter.Fill(dataSet1, "Orders");
orderDetailsAdapter.Fill(dataSet1, "Order Details");
Set the Nested property of the relations to true so that the XML is generated.
// nests the orderdetails within the orders within customers.
// Set the property to false to have the Customers, Orders, OrderDetail records
// displayed consecutively within the tree, (Non-hierarchically).
dataSet1.Relations["CustOrders"].Nested = true;
dataSet1.Relations["OrderDetails"].Nested = true;
Create an in-memory stream in which to point the dataset output and place the XML into the xmlWriter;
System.IO.MemoryStream stream = new System.IO.MemoryStream();
System.Xml.XmlWriter xmlWriter = new System.Xml.XmlTextWriter(stream, m.Text.Encoding.UTF8);
// Shoot the xml into the xmlWriter stream and reset the underlying stream to the beginning
dataSet1.WriteXml(xmlWriter, XmlWriteMode.IgnoreSchema);
stream.Seek(0, System.IO.SeekOrigin.Begin);
Now you would have to obtain the Customers.xsl file from the application directory and load it the XslTransform. The XSL file contains the rules for the transformation from the DataSet XML to the // UltraWebTree XML format.
System.Xml.Xsl.XslTransform xslTransform = new System.Xml.Xsl.XslTransform();
xslTransform.Load(Server.MapPath("Customers.xsl"));
Now load the memory stream into an XPathDocument object so that it can be navigated by the XslTransform.
System.Xml.XPath.XPathDocument xpathDoc = new System.Xml.XPath.XPathDocument(stream);
Perform the transformation from the DataSet XML format to the UltraWebTree XMLformat.
XmlReader xmlReader = xslTransform.Transform(xpathDoc, null);
Create an Xml Document and load it from the transform result and load the XML document into the UltraWebTree
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(xmlReader);
UltraWebTree1.ReadXmlDoc(xmlDoc, true, true);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment