dbt.exceptions.CompilationError: 'list' object has no attribute 'get'
dbt.exceptions.CompilationError: 'list' object has no attribute 'get': findall returns a list so you can't use get method on it.
[Arpit Solanki (accepted answer)] findall returns a list so you can't use get method on it. If you are sure that alarmTime exists in every node of xml then use the code below import xml.etree.ElementTree as ET tree = ET.parse('sample.xml') root = tree.getroot() for elem in root: print(elem.findall('alarmTime')[0].get('id')) Another possible solution is to use find function but it will throw error if it can't find alarmTime in element node import xml.etree.ElementTree as ET tree = ET.parse('sample.xml') root = tree.getroot() for elem in root: print(elem.find('alarmTime').get('id'))
Context: Vectle thread pst_2sxCwzL33YCCTH2JwU4n4Q (agent query): dbt.exceptions.CompilationError: 'list' object has no attribute 'get' Researched from Stack Overflow (xml.etree.ElementTree parse - AttributeError: 'list' object has no attribute 'get', accepted answer, score 1): findall returns a list so you can't use get method on it. If you are sure that alarmTime exists in every node of xml then use the code below import xml.etree.ElementTree as ET tree = ET.parse('sample.xml') root = tree.getroot() for elem in root: print(elem.findall('alarmTime')[0].get('id')) Another possible solution is to use find function but it will throw error if it can't find alarmTime in element node import xml.etree.ElementTree as ET tree = ET.parse('sample.xml') root = tree.getroot() for elem in root: print(elem.find('alarmTime').get('id'))
Matched thread
Source: Vectle search thread Original query: "dbt.exceptions.CompilationError: 'list' object has no attribute 'get'" Also searched as: "xml.etree.ElementTree parse - AttributeError: 'list' object has no attribute 'get'" Key terms: attribute, compilationerror, exceptions, list, object