保留XML属性顺序? [英] Preserving XML attribute order?

查看:96
本文介绍了保留XML属性顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这个问题过去曾被问过,但它们都已追溯到几年前.我想知道是否对Python模块进行了任何更改,例如lxml,minidom或etree,这些更改将使我们能够在不打补丁的情况下将属性顺序保留在XML文件中.

I know this question has been asked in the past, but they have all been dated a few years back. I am wondering if there has been any changes made to Python modules such as lxml, minidom, or etree that will allow us to preserve the attribute order in XML files without patching.

我需要保留顺序,因为我要提供的文件依赖该程序.

I need the order to be preserved as the program I am supplying the files to relies on it.

如果没有更新,最简单的实现方法是什么?

If there are no updates, what's the easiest way to implement this?

推荐答案

在将来的XML库实现中,属性排序的重要性不是要克服的技术限制.

The insignificance of attribute ordering is not a technical limitation to be lifted in future implementations of XML libraries.

属性顺序微不足道 根据 XML建议 :

请注意,起始标记或 空元素标记不重要.

Note that the order of attribute specifications in a start-tag or empty-element tag is not significant.

因此,您不应将设计基于XML的属性的任何特定顺序.

Thus, you should not base your design upon any particular ordering of attributes in XML.

在应用程序绝对必须订购XML属性的极少数情况下,请参见关于属性处理的部分 > XML规范建议或规范的XML建议.

In the very rare circumstances where an application absolutely must order XML attributes, see the section on attribute processing in the XML Normalization Recommendation or the Canonical XML Recommendation.

这篇关于保留XML属性顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆