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
ExecuteScriptsWhether the document’s scripts run while it loads and converts. Default: false. Available since version 26.10.
ExternalResourceHandlerA handler called for each resource the document asks to load; it can allow the resource, skip it or supply its content. Default: null. Available since version 26.10.
Format Input document file type
PageNumberingWhether to generate page numbers for the converted document. Default: false
ResourceLoadingTimeoutSpecifies the timeout of loading the external resources.
SkipExternalResourcesWhether to skip the external resources the document references. Default: true. Content the document carries, local files inside its folder and resources that match WhitelistedResources still load.
UseAsDataSource Use source XML document as a data source
WhitelistedResourcesAbsolute URI prefixes, such as https://cdn.example.com/assets/, of external resources to load while SkipExternalResources is true. Since version 26.10, an entry that is not an absolute URI prefix makes the load fail with InvalidLoadOptionsException.
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", (LoadContext loadContext) => 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", (LoadContext loadContext) => 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.

External resources are not loaded by default, and scripts do not run. Read the Skip loading of external resources article to learn how to allow trusted resources, decide per resource with a handler and run scripts with GroupDocs.Conversion for .NET.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.