1
這裏與條件解析是我的XML結構:XML樹在Python
<images>
<image>
<name>brain tumer</name>
<location>images/brain_tumer1.jpg</location>
<annotations>
<comment>
<name>Patient 0 Brain Tumer</name>
<description>
This is a tumer in the brain
</description>
</comment>
</annotations>
</image>
<image>
<name>brain tumer</name>
<location>img/brain_tumer2.jpg</location>
<annotations>
<comment>
<name>Patient 1 Brain Tumer</name>
<description>
This is a larger tumer in the brain
</description>
</comment>
</annotations>
</image>
</images>
我是新來的Python和想知道如果檢索基於註釋的位置數據:名稱數據是更多鈔票?換句話說,這裏是我的代碼:
for itr1 in itemlist :
commentItemList = itr1.getElementsByTagName('name')
for itr2 in commentItemList:
if(itr2.firstChild.nodeValue == "Patient 1 Liver Tumer"):
commentName = itr2.firstChild.nodeValue
Loacation = it1.secondChild.nodeValue
任何建議,還是我在這裏失去了財產以後? 預先感謝您。
令人印象深刻!謝謝。 –