如何根据 xml 模式更正 xml 文件?

发布于 2024-09-17 22:17:14 字数 267 浏览 0 评论 0原文

有很多文件无意中发生了更改,现在它们与相关架构不匹配。

我想做的是找到错误并自动纠正它们(如果可能的话)。 我查看了 .NET 框架中可用的验证机制。问题是我不知道如何编辑错误的节点。验证事件处理程序为我提供了一个事件参数,该参数包含有关错误本身的一些信息,但不包含节点和发送者对象,该发送者对象是我的 XmlValidationReaderImpl 类型的对象我一无所知,而且我在任何地方都找不到有关此类型的任何信息。

有谁知道如何使用验证机制更正 Xml 文件或者是否有其他可用方法?

There are a lot of files that have changed unintentionally and now they don't match their related schema.

What I want to do is to find the errors and to correct them automatically (if possible).
I looked at the validation mechanism available in .NET framework. The problem is I don't know how I can edit the erroneous node.The validation event handler gives me an event argument that has some information about the error itself but not the node and a sender object that is an object of type XmlValidationReaderImpl which I don't know anything about and I couldn't find any information about this type anywhere.

Does anybody know how I can correct a Xml file using validation mechanism or if there are any other approaches available ?

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

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

发布评论

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

评论(1

⊕婉儿 2024-09-24 22:17:14

我不确定是否使用验证机制,但如果错误的形式过于简单,您始终可以在原始文本中编辑和更正它们。您可以使用文件流来做到这一点。如果您想进一步探索这一点,请告诉我。也许您可以发布一些示例来说明它的外观以及它应该是什么样子。我也许可以立即为您编写函数来纠正这些问题。

I am not sure about using the validation mechanism, but if the errors are simplistic in form you could always edit and correct them in raw text. You can do this by using filestreams. If you would like to explore this further let me know. Maybe you could post some examples of what it looks like, and what its supposed to look like. I might be able to write the function for you to correct these in no time.

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