cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
749
Views
5
Helpful
1
Replies

query_start() example?

cnicasio
Level 1
Level 1

I need to do an XPATH search into CDB, from Python. The functions query_start(), query_result(), etc appear to deal with that. Does anybody have an example of this functions in use?

I have the problem of finding a subset of elements of a large list.....would be very slow to scan the whole list.

Regards

Oscar

1 Reply 1

mvolf
Cisco Employee
Cisco Employee

How large the subset is expected to be? If it is a "small" number, maybe xpath_eval is enough: this is how to find all rule names in all rule-lists in the NACM model that have the action "permit":

>>> names = []
>>> trans.xpath_eval('/nacm/rule-list/rule[action="permit"]/name', (lambda kp, v: names.append(str(v))), None, '/')
>>> names
['any-access', 'tailf-aaa-authentication', 'tailf-aaa-user', 'tailf-webui-user']
>>>