【发布时间】:2017-02-09 00:00:20
【问题描述】:
我正在尝试从具有多级标签的 xml 文件中提取字段。在下面的例子中,
<compound kind="struct">
<name>my-struct</name>
<filename>struct____dt__args.html</filename>
<member kind="variable">
<type>int32_t</type>
<name>count</name>
<anchorfile>struct____dt__args.html</anchorfile>
<anchor>a0fbe49d8b1189286bd817409658eb631</anchor>
<arglist></arglist>
</member>
<member kind="variable">
<type>int32_t</type>
<name>create_type</name>
<anchorfile>struct____dt__args.html</anchorfile>
<anchor>a4e38c7f138891d020cce3c6d7e6bc31e</anchor>
<arglist></arglist>
</member>
<member kind="variable">
<type>size_t</type>
<name>total_size</name>
<anchorfile>struct____dt__args.html</anchorfile>
<anchor>a41ca25bca63ad1fee790134901d8d1c0</anchor>
<arglist></arglist>
</member>
</compound>
我需要解析它并提取“复合”标签中的字段(有多个复合标签具有不同种类的结构/函数/类等,)我只需要 kind=struct 标签,后跟其子项的类型和名称'成员的标签。
struct my-struct:
int32_t count
int32_t create_type
size_t total_size
【问题讨论】:
标签: python xml xml-parsing