saunders_csl
New member
- Joined
- Apr 30, 2010
- Messages
- 3
- Programming Experience
- 3-5
Hi,
I am currently trying to write a basic web application/page that will give the user XML data based on the results of a query. I have all my code working so that a dataset is created populated and XMl is return to the user, however I would also like the schema included in the return. I have spent some time searching around the different object methods and properties and can not seem to find a soultion that will do this in memory. My cirrent code is below:
Dim myOdbcDataAdapter As Data.Odbc.OdbcDataAdapter = New Data.Odbc.OdbcDataAdapter(SelectCmdString, DSNString)
Dim myDataSet As New Data.DataSet()
myOdbcDataAdapter.Fill(myDataSet, "easyStore_dw")
Dim xmlDoc As System.Xml.XmlDataDocument
Dim xmlDec As System.Xml.XmlDeclaration
Dim xmlWriter As System.Xml.XmlWriter
' setup response
Me.Response.Clear()
Me.Response.ContentType = "text/xml"
Me.Response.Charset = "utf-8"
xmlWriter = New System.Xml.XmlTextWriter(Me.Response.OutputStream, System.Text.Encoding.UTF8)
' create xml data document with xml declaration
xmlDoc = New System.Xml.XmlDataDocument(myDataSet)
xmlDoc.DataSet.EnforceConstraints = False
xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)
xmlDoc.PrependChild(xmlDec)
' write xml document to response
xmlDoc.WriteTo(xmlWriter)
xmlWriter.Flush()
xmlWriter.Close()
Response.End()
Any help would be much appriciated.
Kind Regards,
I am currently trying to write a basic web application/page that will give the user XML data based on the results of a query. I have all my code working so that a dataset is created populated and XMl is return to the user, however I would also like the schema included in the return. I have spent some time searching around the different object methods and properties and can not seem to find a soultion that will do this in memory. My cirrent code is below:
Dim myOdbcDataAdapter As Data.Odbc.OdbcDataAdapter = New Data.Odbc.OdbcDataAdapter(SelectCmdString, DSNString)
Dim myDataSet As New Data.DataSet()
myOdbcDataAdapter.Fill(myDataSet, "easyStore_dw")
Dim xmlDoc As System.Xml.XmlDataDocument
Dim xmlDec As System.Xml.XmlDeclaration
Dim xmlWriter As System.Xml.XmlWriter
' setup response
Me.Response.Clear()
Me.Response.ContentType = "text/xml"
Me.Response.Charset = "utf-8"
xmlWriter = New System.Xml.XmlTextWriter(Me.Response.OutputStream, System.Text.Encoding.UTF8)
' create xml data document with xml declaration
xmlDoc = New System.Xml.XmlDataDocument(myDataSet)
xmlDoc.DataSet.EnforceConstraints = False
xmlDec = xmlDoc.CreateXmlDeclaration("1.0", "UTF-8", Nothing)
xmlDoc.PrependChild(xmlDec)
' write xml document to response
xmlDoc.WriteTo(xmlWriter)
xmlWriter.Flush()
xmlWriter.Close()
Response.End()
Any help would be much appriciated.
Kind Regards,