Python 解析xml文件时getChildren for循环中的条件

Python 解析xml文件时getChildren for循环中的条件,python,dictionary,arraylist,pom.xml,Python,Dictionary,Arraylist,Pom.xml,我正试图在forloop中设置一个条件,以适应字典中存储的不需要的数据。我正在读取一个xml文件,希望忽略标记及其值。我只想存储ArtifactId、groupId和version 注: 我正在使用etree进行解析 代码: 如果您能为我的if声明提供指导,我们将不胜感激 unwanted = ['scope', 'type'] #For loops iterated through the file to store data inside the dictionary #data bein

我正试图在forloop中设置一个条件,以适应字典中存储的不需要的数据。我正在读取一个xml文件,希望忽略标记及其值。我只想存储ArtifactId、groupId和version

注:

我正在使用etree进行解析

代码:

如果您能为我的if声明提供指导,我们将不胜感激

unwanted = ['scope', 'type']

#For loops iterated through the file to store data inside the dictionary
#data beind retrived is groupId, artifactId and version
for dep in depend:
    infoList = []
    counter += 1
    for child in dep.getchildren():
        infoList.append(child.tag.split('}')[1])

        #code that I want to make work
        if(child.tag.split('}')[1] == unwanted):
            print('Found unwanted values, not being added to dictionary')
        else:
            continue    
        
        infoList.append(child.text)

    #list where data is being stored
    dependencyInfo[infoList[1]].update({infoList[2] : infoList[3],infoList[4] : infoList[5]})
                   

#print statement of all the data
print("""%i Dependency where found in %s's pom file.""" % (counter,projectName))
print()