What I am trying to do is to output a dataset into an xml document using Dataset.WriteXML(), but one of the things that I can't figure out how to do is to have what I believe are called inner nodes.
What I mean by that is I have client data, but a client can belong to many companies, which I need to show in the xml as strings, so what I was thinking it should look like is...
Currently the code I have for this is as followsCode:<ClientData> <Client> <ClientName> Test Client </ClientName> <Companies> <Company> <CompanyName> Test Name </CompanyName> </Company> </Companies> </Client> </ClientData>
Hopefully someone knows how to achieve this, thanks for any help in advance.Code:Private Function produceXML(ByVal xmlQry As String, ByVal outLocation As String, ByVal dataSetName As String) As String Dim conn As New OleDb.OleDbConnection(connectionString) Dim da As New OleDb.OleDbDataAdapter(xmlQry, conn) Dim ds As New DataSet Dim fs As FileStream Dim sw As StreamWriter Dim outFile As String = "" Dim blExists As Boolean = True conn.Open() Try da.Fill(ds, "Client") Catch ex As Exception logMsg("xmlQuery was invalid, '" & xmlQry & "'") conn.Close() End Try If Not outLocation.EndsWith("\") Then outLocation &= "\" End If While blExists outFile = outLocation & DateTime.Now.Ticks & ".xml" blExists = FileExists(outFile) End While ds.DataSetName = dataSetName fs = New FileStream(outFile, FileMode.Create) sw = New StreamWriter(fs) ds.WriteXml(sw) sw.Close() fs.Close() conn.Close() Return outFile End Function
Satal![]()




Reply With Quote
