0
我想在xml中搜索文件的子字符串與任何模式都不匹配的元素,然後從根中刪除元素。如何知道整個字符串是否與模式部分匹配?
我想知道有其他的方法來搜索是否完整路徑的子串用的模式的一個或不匹配。
我想知道如何從根中刪除匹配項。
您能否讓我得到一些建議。
這裏是我的示例腳本
if __name__ == '__main__':
root = ElementTree()
root.parse('errors.xml')
patterns = ['/cm-audio/src/main/', '/reprogram-manager/']
for error in errors:
file = error.find('file').text
bMatch = False
for p in patterns :
if p in file :
bMattch = True
break
if bMatch == False :
root.remove(error) #it doesn't work.