在 python 中阅读 xml 的轻量级库是什么?
what is a lightweight library to read xml in python?
我需要处理 python 中的一些 XML 个文件。有很多库可供选择,有没有一个轻量级的高效的?我只需要从 XML(下面的示例)中获取作者姓名。另外,我想打开 xml 文件,读取一个 element/attribute,将值保存在变量或列表中,然后立即关闭文件,这样我就不会占用太多内存。我有很多 XML 个文件要处理。
<?xml version="1.0"?>
<catalog>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
</catalog>
您可以使用 python 本机支持 xml documentation
中有更多示例
我需要处理 python 中的一些 XML 个文件。有很多库可供选择,有没有一个轻量级的高效的?我只需要从 XML(下面的示例)中获取作者姓名。另外,我想打开 xml 文件,读取一个 element/attribute,将值保存在变量或列表中,然后立即关闭文件,这样我就不会占用太多内存。我有很多 XML 个文件要处理。
<?xml version="1.0"?>
<catalog>
<book id="bk110">
<author>O'Brien, Tim</author>
<title>Microsoft .NET: The Programming Bible</title>
<genre>Computer</genre>
<price>36.95</price>
<publish_date>2000-12-09</publish_date>
<description>Microsoft's .NET initiative is explored in
detail in this deep programmer's reference.</description>
</book>
</catalog>
您可以使用 python 本机支持 xml documentation
中有更多示例