TClientDataset - XML 映射
我正在尝试将 TClientDataSet 中的数据保存到 XML 文件,但它不喜欢我的某些字段。 帮助文件表示可以通过以下两种方式之一创建定义:使用 \bin 文件夹中的 xmlmapper.exe 文件或使用 IDOMDocument 接口。
问题是,xmlmapper.exe 不存在,而 IDOMDocument 是 Delphi 2009 发布时没有为其编写文档的那些烦人的结构之一。 因此,我必须在不存在的 EXE 或没有文档且没有指示哪些对象实现它或如何创建它们的接口之间进行选择。
有谁知道在这种情况下我应该做什么?
I'm trying to save data in a TClientDataSet to an XML file, but it doesn't like some of my fields. The helpfile says to create a definition, in one of two ways: either with the xmlmapper.exe file in my \bin folder or with an IDOMDocument interface.
Problem is, xmlmapper.exe isn't there, and IDOMDocument is one of those annoying structures that Delphi 2009 was released without writing up documentation for. So I have to choose between a non-existent EXE or an interface with no documentation and no indication of which objects implement it or how to create them.
Does anyone know what I'm supposed to do in this case?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您使用的是 delphi 的 XML 序列化中不支持的字段,则需要创建自己的 XML 加载/保存函数。
这并不难,如果您这样做,该代码可以扩展为其他序列化格式(JSON、CSV、XLSX,...)。
If you are using fields that are unsupported in delphi's XML serialisation, you need to create your own functions for XML loading/saving.
It's not hard, and if you do it, that code can be expanded for other serialisation formats (JSON, CSV, XLSX, ...).
XMLMapper.exe 在我的 \bin 目录中,它也在我的工具菜单下(尽管我可能已将它添加到那里......) 你有什么版本的 Delphi? 我查看了功能矩阵,但我没有看到任何看起来像但所有三个版本都没有的东西。 您可以再次运行安装,看看是否跳过了安装。
XMLMapper.exe is in my \bin directory, it is also under my tools menu (although I may have added it there. . . .) What edition of Delphi do you have? I looked at the feature matrix and I don't see anything that looks like it that isn't in all three editions. You might run your installation again and see if maybe you skipped the installation of it.
您可以查看一些第 3 方 Delphi 书籍(Marco Cantu 有一些),看看它们是否记录了 IDOMDocument。 您还可以查找一些示例。
You might look at some 3rd party Delphi books (Marco Cantu has a few) and see if they document IDOMDocument. You also might look around for some examples.
第三种选择是简单地迭代所有记录,并使用 OmniXML 或 NativeXml 等 XML 库,使用自己编写的代码将字段写入 XML。
这样做的优点是可以完全控制所有字段类型和特定字段的转换。
A third option is to simply iterate over all records and write the fields to XML with self-written code, using a XML library like OmniXML or NativeXml.
This has the advantage to have total control over the conversion of all field types and specific fields.
声明:
or
or
dfBinary
:信息以二进制格式编码。dfXML
:信息以 XML 形式编码,并使用转义序列对扩展字符进行编码。dfXMLUTF8
:信息以 XML 形式编码,扩展字符使用 UTF8 表示。Declaration:
or
or
dfBinary
: Information is encoded in binary format.dfXML
: Information is encoded in XML, with extended characters encoded using an escape sequence.dfXMLUTF8
: Information is encoded in XML, with extended characters represented using UTF8.