This article provides information about business reporting using the XBRL standard, the purpose of XBRL, and how to automate the process of creating XBRL-based business reports in .NET applications. Furthermore, it contains step-by-step methods to parse XBRL and iXBRL files and retrieve data programmatically using C#. Last but not least, it provides some simple ways to validate XBRL and iXBRL files using C#.
eXtensible Business Reporting Language (XBRL)
XBRL is a globally used XML-based standard and file format for business reporting. It makes it easier for various companies and accounting organizations to efficiently and accurately organize, compile, and communicate financial statements or other finance-related information/data. Since XBRL is based on XML (Extensible Markup Language), it uses tags to keep and parse every piece of financial data. iXBRL (inline XBRL) is another variant that makes it possible to keep financial data in a human-readable and machine-readable form at the same time. In contrast with XBRL, iXBRL uses the HTML standard along with some extra tags for figures and statements.
The tags in both, XBRL and iXBRL, are parsed using XBRL-compatible software to retrieve the data. To automate XBRL parsing, Aspose offers Aspose.Finance for .NET API. It is a .NET class library that makes it even easier to create XBRL instances programmatically using C# or VB.NET. In addition, it allows you to parse and validate the XBRL or iXBRL files within the .NET applications. Aspose.Finance for .NET provides the following XBRL/iXBRL manipulation features that you will learn in this article.
You can install Aspose.Finance for .NET from NuGet or download its DLL to manually reference it in your project.
Create XBRL Instance from Scratch in C#
Aspose.Finance for .NET makes it simple to create XBRL instances from scratch. You can also add the schema reference, context, units, items, footnote links, role references, and arc role references in the newly created XBRL instance. The following are the steps to create an XBRL instance:
- Create an instance of the XbrlDocument class.
- Access instances’ collection from XbrlDocument object into XbrlInstanceCollection object.
- Add a new XBRL instance using XbrlInstanceCollection.Add() method.
- Save the XBRL file using XbrlDocument.Save(string) method.
The following code sample shows how to create an XBRL instance in C#.
Once you have created the instance of XBRL, you can insert objects to it which are discussed in the following articles:
Parse XBRL or iXBRL Files in C#
Aspose.Finance for .NET provides an easy way of parsing XBRL files and retrieving their content within a few lines of code. The following sections contain the steps and code samples of how to parse XBRL and iXBRL files.
Parse XBRL Files in C#
The following are the steps to parse an XBRL file using Aspose.Finance for .NET.
- Create an instance of the XbrlDocument class and initialize it with the path of an XBRL file.
- Get the instances in the XBRL into an XbrlInstanceCollection object using XbrlDocument.XbrlInstances property.
- Access the desired XBRL instance from the collection using the XbrlInstance class.
- Parse the content of the XBRL instance.
The following code sample demonstrates how to parse an XBRL file in C#.
Parse iXBRL Files in C#
Parsing an iXBRL file is comparatively easier and can be done using the following steps.
- Create an object of the InlineXbrlDocument class and initialize it with the iXBRL file’s path.
- Access the content of the file using the InlineXbrlDocument object, i.e. InlineXbrlDocument.Facts etc.
The following code sample shows how to parse and read an iXBRL file in C#.
Validate XBRL or iXBRL Files in C#
The XBRL and iXBRL files must comply with the validation rules in the XBRL specification and iXBRL specification respectively. Disobeying the specification rules may invalidate the files. Aspose.Finance for .NET also lets you validate XBRL or iXBRL files in order to find out the errors. The following sections demonstrate how to validate XBRL and iXBRL files.
Validate XBRL Files in C#
The following are the steps to validate an XBRL file:
- Create an instance of the XbrlDocument class.
- Access the instance to be validated from the XbrlInstanceCollection.
- Validate XBRL instance using XbrlInstance.Validate() method.
The following code sample shows how to validate an XBRL file in C#.
Validate iXBRL Files in C#
The below steps are used to validate an Inline XBRL file.
- Create an instance of the InlineXbrlDocument class and initialize it with the iXBRL file’s path.
- Call InlineXbrlDocument.Validate() method.
The following code sample shows how to validate an iXBRL file in C#.
Learn more about the validation error codes and error messages from here.
Explore the API
You can learn more about how to create, parse, and validate XBRL and iXBRL files from the following resource:
Try Aspose.Finance for .NET for Free
Aspose offers a temporary license to evaluate its APIs free of cost. You may also post your request and get a temporary license.