brauch da mal n bissl hilfe beim xml auslesen...
und zwar habe ich eine xml mit folgender struktur:
Code: Alles auswählen
<root>
 <Processors>
  <ProcessorType>TXCPU</ProcessorType> 
   <DeviceFile>
    <FileName>NpTx</FileName> 
    <Version>1_a</Version> 
   </DeviceFile>
 </Processors>
 <CommunicationMedia>
  <CommunicationMediumType>CANA</CommunicationMediumType> 
   <DeviceFile>
    <FileName>NpCan</FileName> 
    <Version>1</Version> 
   </DeviceFile>
   <DriverFile>
    <FileName>CanPci405</FileName> 
    <Version>1</Version> 
   </DriverFile>
 </CommunicationMedia>
</root>Code: Alles auswählen
import xml.etree.ElementTree as et
files = file("project.xml", "r") 
etree = et.parse(files) 
files.close() 
root_tag = etree.getroot() 
for proc in root_tag.findall("Processors"):
    for device in proc.findall("DeviceFile"):
        print device.find("FileName").text
        print device.find("Version").text        #Bis hier gehts!!!
for commed in root_tag.findall("CommunicationMedia"):
    for comtype in commed.getchildren("CommunicationMediumType"):
        for devf in comtype.findall("DeviceFile"):
            print devf.find("FileName").text
            print devf.find("Version").text
        for driver in comtype.findall("DriverFile"):
            print driver.find("FileName").text
            print driver.find("Version").text
