How to View XML File Using C#
In order to view XML file, we’ll use
API which is a feature-rich, powerful and easy to use API for C# platform to be used with any Viewer. Open
package manager, search for Aspose.Tasks and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.Tasks
Steps to View XML via C#
Aspose.Tasks makes it easy for the developers to view the XML file with just few lines of code.
- Load XML file with Project class
- Call the Project.Save method with HtmlSaveOptions as parameters
- Load resultant HTML in default browser with Process.Start
System Requirements
Aspose.Tasks for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, Mono and COM Interop
- Development environment like Microsoft Visual Studio
- Aspose.Tasks for .NET referenced in your project
C# code to view XML
// load XML file in an instance of Project
var project = new Tasks.Project("template.xml");
// create an instance of HtmlSaveOptions
var option = new Tasks.Saving.HtmlSaveOptions();
// convert XML file to HTML format
project.Save(output, option);
// load resultant HTML in default browser
System.Diagnostics.Process.Start(output);