2

我正在尝试使用 pyxb 库解析具有简单和复杂类型的 XML 文件。以下是 XML 结构:

            </Requirement>
            <Section name="Electrical Characteristics">                     
            </Section>
        </Section>
    </Source>
</Requirements>

在通过 pyxb 阅读后,我按以下顺序获取 XML,其中 Requirement 和 section 的顺序发生了变化。

            <Section name="Electrical Characteristics">                     
            </Section>

            </Requirement>
        </Section>
    </Source>
</Requirements>

我编写了一个将 XML 转储到 pyxb 对象的脚本,并且我曾经orderedContent()通过以下方式保留顺序。

ordered_instance = instance.orderedContent()

我在ordered_instance变量中得到空列表。

4

0 回答 0