I need to check to see if the intent value exists or not and if it doesn't exist, I'd like to have it assigned 'UNASSIGNED'
for info in data:
intent = info.getAttribute("intentref")
if (intent) == None:
intent = 'NOT_ASSIGNED'
utterance = info.firstChild.nodeValue
But it's not working. any idea?
Left side - instead of blank, it should say 'UNASSIGNED'.
CodePudding user response:
I think you can do:
intent= info.get(intentref,'NOT_ASSIGNED')
not sure if it's the same for lxml but using "get" like this in other xml parsers allows you to set a default value if not found
CodePudding user response:
I fixed it by the doing the following:
ntent = info.getAttribute("intentref")
if (len(intent)) <1:
intent = 'NOT_ASSIGNED'

