[问题] 如何用python抓取XML中的data (ETREE)

楼主: VivianAnn (薇薇安安)   2022-02-22 16:30:54
各位好
本人有类似以下的XML档(output.xml)必须要用python来处理
希望可以撷取各个tag中的值
我的XML档中有namespace,内容如下:
<data xmlns="urn:ietf:params:ns:netconf:base:1.0">
<interfaces xmlns="http://namespace.net">
<interface>
<name>Interface0</name>
</interface>
<interface>
<name>Interface1</name>
</interface>
</interfaces>
</data>
查了一下网络,有xml.etree这个library可以用
以下是我的code
作者: OrzOGC (洞八达人.拖哨天王)   2022-02-22 20:28:00
这可以用BS吧?
楼主: VivianAnn (薇薇安安)   2022-02-22 22:27:00
bs有尝试,感觉比较慢
作者: alvinlin (林矜业)   2022-02-28 04:05:00
xmltodict 是 Python 中的一个模组
作者: coeric ( )   2022-03-09 17:47:00
我曾经使用xml去做 当我后来用bs4去做 真的觉得是新天地

Links booklink

Contact Us: admin [ a t ] ucptt.com