ISO20022.Parser

ISO20022.Parser is a an advanced and powerful dotnet library tailored to streamline the parsing of ISO 20022 XML messages. Designed with developers in mind, ISO20022.Parser simplifies the integration of this complex financial messaging standard into your applications, saving time and effort. Whether you're handling payments, securities, or trade messages, this library offers a seamless solution for incorporating ISO 20022 standards into your workflows with ease and efficiency.

Features

  • Automate your ISO 20022 Message parsing with pre-defined rules

Install

dotnet add package ISO20022.Parser
Install-Package ISO20022.Parser

Extract Information from ISO 20022 Messages

ISO20022.Suite library help to parse or extract all the detailed information from the ISO20022 message based on predefined parsing rules.

Usage
                                
                                    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 uniquiId) =>
                                            {
                                              //DataSet ds:  camt.053.xml will have multiple messages in a file and this dataset will have the parsed data of the given message. Each message parsed will be callbacked over here for the further process.
                                               // messageUniqueId :  As  camt.053 will have multiple message, each message will identified with the given messageUniqueId. 
                                               // uniqueId: this id is represent the unique file Id. Meaning each passed file has been represent by the given Id. 
                                                Task task = Task.Run(() =>
                                                {
                                                    // either we can transform to CSV/Excel or transfered to DB using bulk DB operation
                                                    string dateTime = DateTime.Now.ToString("ddmmyyyyHHmmssfff");
                                                    foreach(DataTable dt in ds.Tables)
                                                    {
                                                        ExportDataTableToCsv(dt, @$"export\{messageUniqueId}_{dt.TableName}_{uniquiId}.csv");
                                                    }
                                                   
                                                });
                                                return task;
                                            });                                           
                                            Console.Read();
                                        }
                                    
                                        static void ExportDataTableToCsv(DataTable dataTable, string filePath)
                                        {
                                            if (!File.Exists(filePath))
                                            {
                                                File.Create(filePath).Close();
                                            }
                                            // Create a StreamWriter to write to the CSV file
                                            using (StreamWriter writer = new StreamWriter(filePath))
                                            {
                                                // Write the header row with column names
                                                foreach (DataColumn column in dataTable.Columns)
                                                {
                                                    writer.Write(column.ColumnName);
                                                    writer.Write(",");
                                                }
                                                writer.WriteLine(); // Move to the next line
                                    
                                                // Write the data rows
                                                foreach (DataRow row in dataTable.Rows)
                                                {
                                                    foreach (object item in row.ItemArray)
                                                    {
                                                        writer.Write(item);
                                                        writer.Write(",");
                                                    }
                                                    writer.WriteLine(); // Move to the next line
                                                }
                                            }
                                        }
                                    
                                    }
                                
                            
Parsing Rules

Please follow the Parsing Rules example given in the data directory of the repository. Mapping Rules should follow below model class structure

                                
                                    public class MappingRules
                                    {
                                        public string Namespace { get; set; }
                                        public List Mappings { get; set; }
                                    }

                                    public class MappingTable
                                    {
                                        public string NodeName { get; set; }
                                        public string XPath { get; set; }
                                        public IList 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 given example is in json file. Suppose you want to store Parsing rules in Database. Now you need to override the ParsingRules class method DeserializeRules.

                                
                                    public class ParsingDatabaseRules : ParsingRules
                                    {
                                        public override void DeserializeRules()
                                        {
                                        //MapParsingRules is of type IList?
                                            MapParsingRules = GetMyRulesFromDB();
                                        }
                                    }