【发布时间】:2018-01-20 13:27:28
【问题描述】:
我有如下的 xml 文件。
<sbe:messageSchema xmlns:sbe="http://www.fixprotocol.org/ns/simple/1.0"
description="something"
byteOrder="littleEndian">
<sbe:message name="DummyMsg" id="99" description="Placeholder message. Uses otherwise unused enums and composites so sbe compiles them.">
<field name="msgType" id="1" type="MsgType" />
<field name="minimumSbeSchemaVersion" id="2" type="MinimumSbeSchemaVersion"/>
</sbe:message>
</sbe:messageSchema>
xml 文件有多个 sbe:messageSchema 记录。
尝试使用lxml.etree。如果我这样做for child in root,那么我会得到描述、字节顺序等,但不会得到 sbe:messageSchema。
此外,如果我尝试root.iterfind('./sbe:message'),则会收到类似 sbe not found 之类的错误。
我想得到sbe:messageSchema and its fields。请帮忙。
【问题讨论】:
-
在这里查看答案,他们可以帮助你。 stackoverflow.com/questions/26991957/…
标签: xml python-2.7 lxml