Validate XBRL Files via C#
Validating financial reports in XBRL format without needing Microsoft Office installed or any other software.
How to Validate XBRL Files
Follow the steps in code snippet or enhance it as of your application needs for validating extensible business reporting language XBRL documents. Be sure of having validating requirements within your application.
- Load XBRL file using XbrlDocument class Instance.
- To check validity of the loaded file, so that it must match with XBRL specification
- To check the validatity, use Validate() method of XbrlInstance class.
Validation Requirement
To proceed for validating XBRL documents, .NET Finance API is the main requirement to be included within application.
Install it via command line as
nuget install Aspose.Finance
or via Package Manager Console of Visual Studio withInstall-Package Aspose.Finance
.Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .
C# code to validate XBRL files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XbrlDocument xbrlDoc = new XbrlDocument(XbrlFilePath + @"IdScopeContextPeriodStartAfterEnd.xml"); | |
XbrlInstanceCollection xbrlInstances = xbrlDoc.XbrlInstances; | |
XbrlInstance xbrlInstance = xbrlInstances[0]; | |
xbrlInstance.Validate(); | |
if (xbrlInstance.ValidationErrors.Count > 0) | |
{ | |
foreach (ValidationError validationError in xbrlInstance.ValidationErrors) | |
{ | |
if(validationError.Code == ValidationErrorCode.ContextPeriodStartAfterEnd) | |
{ | |
ContextValidationError contextValidationError = validationError as ContextValidationError; | |
Console.WriteLine("Validation error: end date is before start date in context " + contextValidationError.Object.Id); | |
} | |
else | |
{ | |
Console.WriteLine("Find validation error:" + validationError.Message); | |
} | |
} | |
} |
Other Validating Options
XBRL (Inline Extensible Business Reporting Language)