GroupDocs.Conversion provides the XmlLoadOptions class to offer fine-grained control over how XML documents are processed during conversion. This flexibility is particularly useful when working with XML data sources, applying XSL transformations, or handling external resources.
Provides an XSLT document stream to apply XSLT transformations, typically for converting to HTML.
These options enable you to customize the XML document loading process based on your specific requirements.
Convert XML as a Data Source to a Spreadsheet
This example demonstrates how to use an XML document as a data source and convert it into a spreadsheet format:
importcom.groupdocs.conversion.Converter;importcom.groupdocs.conversion.options.convert.SpreadsheetConvertOptions;importcom.groupdocs.conversion.options.load.XmlLoadOptions;publicclassXmlToSpreadsheet{publicstaticvoidconvert(){// Load XML as a data source
XmlLoadOptionsloadOptions=newXmlLoadOptions();loadOptions.setUseAsDataSource(true);// Initialize the converter with XML and load options
try(Converterconverter=newConverter("data.xml",()->loadOptions)){// Conversion options for spreadsheet
SpreadsheetConvertOptionsoptions=newSpreadsheetConvertOptions();// Convert XML to XLSX
converter.convert("converted.xlsx",options);}}publicstaticvoidmain(String[]args){convert();}}
data.xml is sample file used in this example. Click here to download it.
converted.xlsx is converted XLSX document. Click here to download it.
Skipping the Loading of External Resources
External resources refer to data or content that is linked from within an XML document but stored separately. This includes:
Document Type Definitions (DTDs) or XML Schemas (XSDs)
External entities
XSLT stylesheets
Linked images or multimedia content
Data sources referenced in the XML
Why Skip External Resources?
You may want to skip loading external resources in the following cases:
Unavailable Resources: When external resources are missing or inaccessible.
Security Concerns: To prevent XML External Entity (XXE) attacks.
Performance Optimization: To improve conversion speed by avoiding unnecessary external calls.