.NETISO20022.Parser

ISO20022.Parser

Parse and validate ISO 20022 XML messages in .NET.

ISO20022.Parser is a .NET library built to streamline the parsing of ISO 20022 XML messages. It simplifies integrating a complex financial messaging standard into your own applications — whether you are handling payments, securities or trade messages — without hand-rolling XPath against every message variant.

6.1s60MB camt.053 · 129,769 entries

What it does

  • Automate ISO 20022 message parsing with pre-defined rules
  • Blazing fast parsing of large ISO 20022 XML files
  • Low and predictable memory usage for efficient processing
  • Out-of-the-box support for all major ISO 20022 message variants
  • Seamless integration into enterprise ecosystems
  • Customisable parsing rules to fit specific business needs
  • Robust validation against ISO 20022 XSD schemas

Install

.NET CLI
dotnet add package ISO20022.Parser
Package Manager
Install-Package ISO20022.Parser

Performance

Parses a 60MB camt.053.001.02 file containing 129,769 <Ntry> records in 6.1 seconds — no memory bloat, no third-party dependencies.

Extract information from ISO 20022 messages

The parser extracts detailed information from a message based on pre-defined parsing rules. A file may contain many messages; each one is handed back through the callback with its own identifier, so you can stream results into CSV, Excel or a bulk database write without holding the whole file in memory.

csharpProgram.cs
using System.Data;
using ISO20022.Parser;

public class Program
{
    private static async Task Main(string[] args)
    {
        IParsingService parsingService = new ParsingService(
            new ParsingJsonRules(@"data\parsing_rules.json"), "Document");

        await parsingService.ParseXmlAsync(@"data\camt.053.xml",
            (DataSet ds, Guid messageUniqueId, Guid uniqueId) =>
        {
            // ds:              the parsed data for this message.
            // messageUniqueId: identifies each message within the file.
            // uniqueId:        identifies the file itself.
            Task task = Task.Run(() =>
            {
                foreach (DataTable dt in ds.Tables)
                {
                    ExportDataTableToCsv(dt,
                        @$"export\{messageUniqueId}_{dt.TableName}_{uniqueId}.csv");
                }
            });
            return task;
        });

        Console.Read();
    }

    static void ExportDataTableToCsv(DataTable dataTable, string filePath)
    {
        if (!File.Exists(filePath))
        {
            File.Create(filePath).Close();
        }

        using (StreamWriter writer = new StreamWriter(filePath))
        {
            foreach (DataColumn column in dataTable.Columns)
            {
                writer.Write(column.ColumnName);
                writer.Write(",");
            }
            writer.WriteLine();

            foreach (DataRow row in dataTable.Rows)
            {
                foreach (object item in row.ItemArray)
                {
                    writer.Write(item);
                    writer.Write(",");
                }
                writer.WriteLine();
            }
        }
    }
}

Parsing rules

Follow the parsing rules example in the data directory of the repository. Mapping rules should follow the model class structure below.

csharp
public class MappingRules
{
    public string Namespace { get; set; }
    public List<MappingTable> Mappings { get; set; }
}

public class MappingTable
{
    public string NodeName { get; set; }
    public string XPath { get; set; }
    public IList<MappingColumn> Columns { get; set; }
}

public class MappingColumn
{
    public int OrderNumber { get; set; }
    public string NodeName { get; set; }
    public string XPath { get; set; }
    public string DataType { get; set; }
    public int MinLength { get; set; }
    public int MaxLength { get; set; }
    public int fractionDigits { get; set; }
    public int totalDigits { get; set; }
}

Override the parsing rules

The supplied example reads rules from a JSON file. To store them somewhere else — a database, say — override the ParsingRules class method DeserializeRules.

csharp
public class ParsingDatabaseRules : ParsingRules
{
    public override void DeserializeRules()
    {
        // MapParsingRules is of type IList<MappingRules>?
        MapParsingRules = GetMyRulesFromDB();
    }
}
Next step

Running this in production?

We wrote these libraries and we run them. If you are planning an ISO 20022 migration, we can tell you quickly where the hard parts actually are.