C# 中的 OFX​​ 文件解析器

发布于 2024-09-11 22:23:25 字数 271 浏览 0 评论 0原文

我正在寻找 C# 中的 OFX​​ 文件解析器库。我在网上搜索过,但似乎没有。有谁知道任何优质的 C# OFX 文件解析器。我需要处理一些 OFX 格式的银行对账单文件。

更新 我设法找到了一个用于解析 OFX 解析器的 C# 库。

这是ofx Sharp 的链接。该代码库似乎是启动我的解决方案的最佳案例。

I am looking for an OFX file parser library in C#. I have search the web but there seems to be none. Does anyone know of any good quality C# OFX file parser. I need to process some bank statements files which are in OFX format.

Update
I have managed to find a C# library for parsing OFX parser.

Here is the link ofx sharp. This codebase seems to be the best case to startup my solution.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

泛滥成性 2024-09-18 22:23:25

我尝试使用 ofx Sharp 库,但意识到它不起作用,因为该文件不是有效的 XML ...它似乎可以解析,但具有空值...

我在 OFXDocumentParser.cs 中进行了更改,我首先修复文件变成有效的 XML,然后让解析器继续。不确定您是否遇到过同样的问题?

在方法内部:

private string SGMLToXML(string file)

我首先添加了几行,将文件保存到新文件中,然后让 SqmlReader 在以下代码之后处理:

string newfile = ParseHeader(file);

newfile = SGMLToXMLFixer.Fix_SONRS(newfile);
newfile = SGMLToXMLFixer.Fix_STMTTRNRS(newfile);
newfile = SGMLToXMLFixer.Fix_CCSTMTTRNRS(newfile);


//reader.InputStream = new StringReader(ParseHeader(file));
reader.InputStream = new StringReader(newfile);

SGMLToXMLFixer 是我添加到 OFXSharp 库中的新类。它基本上扫描所有打开的标签并验证它是否也有结束标签。

namespace OFXSharp
{
    public static class SGMLToXMLFixer
    {
        public static string Fix_SONRS(string original) 
        { .... }

        public static string Fix_STMTTRNRS(string original) 
        { .... }

        public static string Fix_CCSTMTTRNRS(string original) 
        { .... }

        private static string Fix_Transactions(string file, string transactionTag, int lastIdx, out int lastIdx_new) 
        { .... }

        private static string Fix_Transactions_Recursive(string file_modified, int lastIdx, out int lastIdx_new) 
        { .... }

    }
}

I tried to use the ofx sharp library, but realised it doesn't work is the file is not valid XML ... it seems to parse but has empty values ...

I made a change in the OFXDocumentParser.cs where I first fix the file to become valid XML and then let the parser continue. Not sure if you experienced the same issue?

Inside of the method:

private string SGMLToXML(string file)

I added a few lines first to take file to newfile and then let the SqmlReader process that after the following code:

string newfile = ParseHeader(file);

newfile = SGMLToXMLFixer.Fix_SONRS(newfile);
newfile = SGMLToXMLFixer.Fix_STMTTRNRS(newfile);
newfile = SGMLToXMLFixer.Fix_CCSTMTTRNRS(newfile);


//reader.InputStream = new StringReader(ParseHeader(file));
reader.InputStream = new StringReader(newfile);

SGMLToXMLFixer is new class I added into the OFXSharp library. It basically scans all the tags that open and verifies it has a closing tag too.

namespace OFXSharp
{
    public static class SGMLToXMLFixer
    {
        public static string Fix_SONRS(string original) 
        { .... }

        public static string Fix_STMTTRNRS(string original) 
        { .... }

        public static string Fix_CCSTMTTRNRS(string original) 
        { .... }

        private static string Fix_Transactions(string file, string transactionTag, int lastIdx, out int lastIdx_new) 
        { .... }

        private static string Fix_Transactions_Recursive(string file_modified, int lastIdx, out int lastIdx_new) 
        { .... }

    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文