ISO20022.Parser
1.0.0
See the version list below for details.
dotnet add package ISO20022.Parser --version 1.0.0
NuGet\Install-Package ISO20022.Parser -Version 1.0.0
<PackageReference Include="ISO20022.Parser" Version="1.0.0" />
paket add ISO20022.Parser --version 1.0.0
#r "nuget: ISO20022.Parser, 1.0.0"
// Install ISO20022.Parser as a Cake Addin #addin nuget:?package=ISO20022.Parser&version=1.0.0 // Install ISO20022.Parser as a Cake Tool #tool nuget:?package=ISO20022.Parser&version=1.0.0
ISO 20022 Parsing .Net 8 Library
ISO20022.Parser is the .Net 8 library which help to parse ISO 200022 messages in the fastes way possible with the predefined rule sets.
NOTE: MXParser has been deprecated. Please switch to ISO20022.Parser
Features
- Parse the ISO 20022 XML Message with pre-defined rules.
- Rules can be in JSON structure or Database structured.
Install the ISO20022.Parser
NuGet package.
- .NET CLI
dotnet add package ISO20022.Parser
- Package Manager
Install-Package ISO20022.Parser
Features in details:
Parsing the ISO 20022 Messages
using System.Data;
using System.Diagnostics;
using ISO20022.Parser;
public class Program
{
private static async Task Main(string[] args)
{
Stopwatch stopwatch = new();
stopwatch.Start();
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;
});
stopwatch.Stop();
TimeSpan elapsedTime = stopwatch.Elapsed;
// Print the elapsed time
Console.WriteLine("Elapsed Time: " + elapsedTime);
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
}
}
}
}
NOTE The library can parse the given 60.6MB xml data file in 00:00:19 seconds with 4 Cores 8 Logical Processor with 16 MB of RAM.
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<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 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.
For Example:
public class ParsingDatabaseRules : ParsingRules
{
public override void DeserializeRules()
{
//MapParsingRules is of type IList<MappingRules>?
MapParsingRules = GetMyRulesFromDB();
}
}
Sample Files
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on ISO20022.Parser:
Package | Downloads |
---|---|
ISO20022.Suite
ISO 20022 is the dotnet library which help to parse, create ISO 200022 messages in the fastes way possible with the predefined rule sets. It also helps to convert your ISO 20022 XSD to JSON |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 109 | 10/16/2024 |
1.0.0 | 132 | 9/4/2024 |
1.0.0-beta | 84 | 9/4/2024 |