|
As shown in the following code:
------------------------------
// The web service method returns an XmlDataDocument object
public XmlDataDocument TDBinding (string strHostcustid / * user input customer number * /)
{
DataSet ds = new DataSet ();
XmlDataDocument xd;
DataColumn parentCol;
DataColumn childCol;
// Two tables for accessing the database through ODBC, one is the main table and the other is the detailed table
OdbcConnection con = new OdbcConnection ("DSN = 137");
OdbcDataAdapter daCust = new OdbcDataAdapter ("select * from PData1.T01_PARTY where Host_Cust_Id = '" + strHostcustid + "'", con);
OdbcDataAdapter daEvnt = new OdbcDataAdapter ("select * from PData1.t05_financial_event_hm where Host_Cust_Id = '" + strHostcustid + "'", con);
// Put two result sets into dataset after query and return
daCust.Fill (ds, "Customer");
daEvnt.Fill (ds, "Event");
xd = new XmlDataDocument (ds);
return xd;
}
The XML format returned by this method is as follows:
<NewDataSet>
<Customer>
...
</ Customer>
<Event>
...
</ Event>
<Event>
...
</ Event>
<Event>
...
</ Event>
</ NewDataSet>
Because a Customer will have multiple events, this looks very long. I hope that the above xml can be adjusted to the following format, which is to indent the result set of event one level further:
<NewDataSet>
<Customer>
...
</ Customer>
<CustomerEvent>
<Event>
...
</ Event>
<Event>
...
</ Event>
</ CustomerEvent>
</ NewDataSet>
Thank you. |
|