Python 3 XML findall空输出

2024-10-03 11:17:46 发布

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

我正试图解决以下问题:

我想得到标记的'type'属性(cpe-23标记是可选的,在xmlschema中是任何类型的)

<cpe-23:deprecated-by ... type="NAME_CORRECTION"/>

在stackoverflow中阅读其他问题后,我得到了以下代码:

^{pr2}$

我现在的问题是,我只得到一个空的输出,我的程序以代码:0在

有什么办法解决这个问题吗?在

先谢谢你!在

源(XML文件):

<cpe-list ...>
    <generator>
       ...
    </generator>
    <cpe-item name="cpe:/a:3com:tippingpoint_ips_tos:2.2.3" deprecated="true" deprecation_date="2010-12-28T17:36:02.240Z">
        <title xml:lang="en-US">3Com TippingPoint IPS TOS 2.2.3</title>
        <cpe-23:cpe23-item name="cpe:2.3:a:3com:tippingpoint_ips_tos:2.2.3:*:*:*:*:*:*:*">
          <cpe-23:deprecation date="2010-12-28T12:36:02.240-05:00">
            <cpe-23:deprecated-by name="cpe:2.3:o:3com:tippingpoint_ips_tos:2.2.3:*:*:*:*:*:*:*" type="NAME_CORRECTION"/>
          </cpe-23:deprecation>
        </cpe-23:cpe23-item>
    </cpe-item>
    <cpe-item ...>
        ...
    </cpe-item>
    ...
</cpe-list>

Tags: 代码name标记bytypeitemlistdeprecated