orderedContent PyXB返回空列表

2024-05-16 00:26:16 发布

您现在位置:Python中文网/ 问答频道 /正文

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

你知道吗 你知道吗

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

在通过pyxb读写之后,我按照以下顺序得到了XML,其中需求和部分的顺序发生了变化

你知道吗 你知道吗

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

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

我编写了一个脚本,将XML转储到pyxb对象,并使用orderedContent()以以下方式保持顺序

ordered_instance = instance.orderedContent()

我在ordered_instance变量中得到一个空列表


Tags: 文件instancename类型source顺序sectionxml