我有一個XML字符串,我想修改特定接口的模型類型。需要幫助來修改與python xml
<domain type='kvm'>
<devices>
<interface type='network'>
<mac address='52:54:00:a8:fe:3d'/>
<source network='ovirtmgmt'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='52:54:00:a8:fe:7d'/>
<source network='nat'/>
<model type='virtio'/>
</interface>
<interface type='network'>
<mac address='52:80:00:a8:66:20'/>
<source network='vm'/>
<model type='virtio'/>
</interface>
</devices>
</domain>
現在,我要換模型type='e1000'
其中source network='nat'
。我怎樣才能做到這一點?
敢肯定你能找到eveythin你所需要的'https://開頭docs.python.org/3 /庫/ xml.etree.elementtree.html' –
[LXML] (http://lxml.de/)是另一個最愛。 – wwii