Load XML document with options

GroupDocs.Conversion provides XmlLoadOptions to give you control over how the source XML document will be processed. The following options could be set:

OptionDescription
BasePathSpecifies the base path/url for the HTML
EncodingSpecifies the encoding to be used to load the document. If not specified, the encoding will be determined from the document’s character set attribute
Format Input document file type
PageNumberingWhether to generate page numbers for the converted document. Default: false
ResourceLoadingTimeoutSpecifies the timeout of loading the external resources.
SkipExternalResourcesIf enabled, the external resources (except for those listed in WhitelistedResources) will not be loaded during the conversion.
UseAsDataSource Use source XML document as a data source
WhitelistedResourcesSpecifies which external resources will be loaded even when the loading of other external resources is restricted.
XslFoFactory  XSL document stream to convert XML-FO using XSL.
XsltFactory  XSLT document stream to convert XML performing XSL transformation to HTML.

Convert XML as a data source to a spreadsheet

The following code snippet shows how to use XML as a data source and convert it to a spreadsheet:

using (Converter converter = new Converter("data.xml", () => new XmlLoadOptions
{
    UseAsDataSource = true
}))
{
    SpreadsheetConvertOptions options = new SpreadsheetConvertOptions();
    converter.Convert("converted.xlsx", options);
}

Convert XML transformed through XSLT to a PDF:

The following code shows how to convert a XML transformed through XSLT to a PDF:

using (var converter = new Converter("books.xml", () => new XmlLoadOptions
   {
       XsltFactory = () => File.OpenRead("books.xsl")
   }))
{
    var options = new PdfConvertOptions();
    converter.Convert("converted.pdf", options);
}

Skip loading of external resources

External resources refer to data or content that is referenced or linked from within an XML document but is stored separately, typically in separate files or locations. Common external resources include DTDs or XML schemas, entities, XSLT Stylesheets, data sources, images, multimedia, and so on.

In some cases, you may want to skip loading all or just some of the external resources during the conversion. For example, when these resources become unavailable. Read the Skip loading of external resources article to learn how to do this with GroupDocs.Conversion for .NET.