Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim doc As New XmlDocument()
doc.LoadXml("...")
txtOuterXml.Text = doc.OuterXml
txtOuterXml.Select(0, 0)
' Use an XmlTextWriter to format.
' Make a StringWriter to hold the result.
Using sw As New System.IO.StringWriter()
' Make the XmlTextWriter to format the XML.
Using xml_writer As New XmlTextWriter(sw)
xml_writer.Formatting = Formatting.Indented
doc.WriteTo(xml_writer)
xml_writer.Flush()
' Display the result.
txtFormatted.Text = sw.ToString()
End Using
End Using
txtFormatted.Select(0, 0)
End Sub
Document의 outerXml을 String으로 전환할때 Formatting적용.
'Xml Formatting
Dim settings As XmlWriterSettings = New XmlWriterSettings()
settings.Indent = True
settings.NewLineOnAttributes = True
Dim builder As New StringBuilder()
Dim writer As XmlWriter = XmlWriter.Create(builder, settings)
OrgDoc.Save(writer)
msgbox(builder.toString)
Document의 Save(xmlwriter)를 이용하여 Stringbuilder에 formatting적용.
'VB.net & WPF & C#' 카테고리의 다른 글
Call by reference, Call by value (0) | 2017.03.16 |
---|---|
Mathematical Expressions Evaluator for .NET(formula parser) (0) | 2017.03.14 |
VB.net XmlNode Name 바꾸기. (0) | 2017.01.04 |
WPF vb.net Textblock - 특정 단어 fontstyle 주기, 동적으로 text 바꾸기 (0) | 2016.12.27 |
VB.net WPF Bitmap -> ImageSource -> ImageBrush (0) | 2016.12.26 |