Conversión de un String XML a un DataTable


/ Published in: VB.NET
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Public Function StrXml2Table(ByVal StrXML As String) As DataTable
  2. Dim ms As MemoryStream
  3. Dim returnMs As New DataTable()
  4. Try
  5. Dim buf() As Byte
  6. Dim ds As New DataSet
  7.  
  8. buf = System.Text.UTF8Encoding.ASCII.GetBytes(StrXML)
  9. ms = New MemoryStream(buf)
  10.  
  11. ds.ReadXml(ms)
  12. Return ds.Tables(0)
  13. Catch ex As Exception
  14. ' Hacer algo o mostrar mensaje de error
  15. Return returnMs
  16. Finally
  17. If Not ms Is Nothing Then
  18. ms.Close()
  19. End If
  20. End Try
  21. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.