我希望12345
使用NodeID
获得python's DOM
。
这是XML:
<?xml version="1.0" ?>
<Inventory version="2.0">
<Component Classname="DCIM_ControllerView" Key="RAID.Slot.1-1">
<PROPERTY NAME="NodeID" TYPE="string">
<VALUE>20161210161621</VALUE>
<DisplayValue>20161210161621</DisplayValue>
</PROPERTY>
</Component>
<Component Classname="DCIM_SystemView" Key="System.Embedded.1">
<PROPERTY NAME="NodeID" TYPE="string">
<VALUE>12345</VALUE>
<DisplayValue>12345</DisplayValue>
</PROPERTY>
</Component>
</Inventory>
答案 0 :(得分:0)
尝试这样的事情:
import xml.etree.ElementTree
e = xml.etree.ElementTree.fromstring(theXmlString) # or from file
e.findall("Component[@Key='RAID.Slot.1-1']/PROPERTY/VALUE")[0].text