【发布时间】:2012-08-30 16:24:32
【问题描述】:
我有这个 XML 文件:
<domain type='kmc' id='007'>
<name>virtual bug</name>
<uuid>66523dfdf555dfd</uuid>
<os>
<type arch='xintel' machine='ubuntu'>hvm</type>
<boot dev='hd'/>
<boot dev='cdrom'/>
</os>
<memory unit='KiB'>524288</memory>
<currentMemory unit='KiB'>270336</currentMemory>
<vcpu placement='static'>10</vcpu>
现在,我想解析它并获取它的属性值。例如,我想获取 uuid 字段。那么在 Python 中获取它的正确方法应该是什么?
【问题讨论】:
-
你试过什么?谷歌搜索“python xml”会产生很多非常有用的结果,这些结果应该会为您指明正确的方向。
-
有很多例子,但没有指向我想去的方向。我想获取属性值。我看到的示例是转换为 xml 文件或转换为 xml 文件
标签: python xml xml-parsing python-2.7