Hay veces en las que necesitamos mostrar un XML formateado como tal en un textbox. Veamos una posible solución en ASP .NET (visual basic):
‘Cargamos el documento xml
Dim docXml As New XmlDocument()
docXml.LoadXml(<ruta_del_xml_a_mostrar>)
‘Cargamos el xml indentado en la variable strBuilder
Dim strBuilder As New StringBuilder()
Dim opciones As New XmlWriterSettings()
opciones.Indent = True
Dim writer As XmlWriter = XmlWriter.Create(strBuilder, opciones)
docXml.WriteTo(writer)
writer.Close()
‘Mostramos el xml indentado en el textbox
TextBox1.Text = strBuilder.ToString()
Comentarios recientes