Click here to Skip to main content
15,897,704 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Public Function ConvertDataSetToXML(ByVal xmlDS As DataSet) As String
Dim stream As MemoryStream = Nothing
Dim writer As XmlTextWriter = Nothing
Try
stream = New MemoryStream()
' Load the XmlTextReader from the stream
writer = New XmlTextWriter(stream, Encoding.Unicode)
' Write to the file with the WriteXml method.
xmlDS.WriteXmlSchema(writer)
Dim count As Integer = CInt(stream.Length)
Dim arr As Byte() = New Byte(count - 1) {}
stream.Seek(0, SeekOrigin.Begin)
stream.Read(arr, 0, count)
Dim utf As New UnicodeEncoding()
Return utf.GetString(arr).Trim()
Catch
Return [String].Empty
Finally
If writer IsNot Nothing Then
writer.Close()
End If
End Try
End Function
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900