Private Sub OutputDataSetAsXML(ByRef dsSource As System.Data.DataSet) 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(dsSource) 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() End Sub
You need to create an account or log in to post comments to this site.