You can create a XML document, by using the basic XmlTextWriter class. If you want to understand how you can read the  article How to use XMLTextWriter to create an XML document in VB.NET. By default, the XmlTextWriter creates an XML file that has all its elements lumped together in a single line without any helpful carriage returns or indentation. If you open the file with Microsoft Internet Explorer you don’t see this limitation because Internet Explorer uses a style sheet to give the XML a more readable (and more colorful) appearance. However, if you open the XML document in Notepad, you can see the difference.

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

Although additional formatting isn’t required, it can make a significant difference if you want to read your XML files in Visual Studio, Notepad, or another text editor. Fortunately, the XmlTextWriter supports formatting; you just need to enable it, as follows:


‘ Set it to indent output.
W.Formatting = Formatting.Indented


‘ Set the number of indent spaces.
W.Indentation = 5