Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

So, I have some data in the form of:

<foo><bar>test</bar></foo>

What .NET classes/functions would I want to use to convert this to something pretty and write it out to a file looking something like this:

<foo>
   <bar>
       test
   </bar>
</foo>

Be specific on the functions and classes please, not just "use System.XML". There seems to be a lot of different ways to do things in .NET using XML :(

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
539 views
Welcome To Ask or Share your Answers For Others

1 Answer

Using the System.Xml.XmlDocument class...

Dim Val As String = "&lt;foo&gt;&lt;bar&gt;test&lt;/bar&gt;&lt;/foo&gt;"
Dim Xml As String = HttpUtility.HtmlDecode(Val)

Dim Doc As New XmlDocument()
Doc.LoadXml(Xml)

Dim Writer As New StringWriter()
Doc.Save(Writer)

Console.Write(Writer.ToString())

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...