【问题标题】:Rearrange the attributes in a node lxml [duplicate]重新排列节点lxml中的属性[重复]
【发布时间】:2013-07-31 07:23:14
【问题描述】:

我有一个像

这样的元素节点
<Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Id="rId61" Target="media/image1.png"/>

我需要按顺序对属性进行排序。输出应该是这样的

<Relationship Id="rId61" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="media/image1.png"/>

如何重新排列?目前我正在使用 lxml 库

谢谢

【问题讨论】:

  • @falsetru 那太完美了...谢谢..

标签: python python-2.7 lxml elementtree


【解决方案1】:

无法使用lxml 设置元素属性的特定顺序。 element.attrib 是字典,python 中的字典是无序集合。

另见:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-11
    相关资源
    最近更新 更多