用于纠正 xml 元素顺序的工具/脚本
我正在使用自定义工具将数据从专有格式转换为 Xml。 但是,生成的 Xml 元素(看似)是随机顺序的,因此 Xml 文件不再与架构匹配。
修复该工具的库已计划,但我现在需要快速修复(文件很大,因此手动修复 xml 将非常耗时)。是否有任何工具/脚本可以根据架构修复 Xml 子元素的顺序?如果它沿着树向下移动并在途中重新排序每个元素的子元素就足够了。
I am using a custom tool for converting data from a proprietary format to Xml.
However the generated Xml elements are in (seemingly) random order, so that the Xml file does not match the schema anymore.
Fixing the libraries of the tool is scheduled, but i need a quick fix for now (the files are big so fixing the xml manually would be very time-consuming). Is there any tool/script that can fix the order of Xml child elements according to a schema? It would be enough if it would go down the tree and on the way reorder the children of each element.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我通过编写一个小的 C# 程序来重新排序元素来解决这个问题。结果发现总是相同的 4 种类型的元素使它们的孩子的顺序随机化,因此对它们进行排序并不太复杂。
I solved the problem by writing a small C# program that reordered the elements. turned out it always were the same 4 types of elements that got their childrens' order randomized, so sorting those was not too complicated.