python xpath_eval() vs. xpath_eval_expr()

yfherzog
Cisco Employee
Cisco Employee

Hi,

I've been trying to use both xpath_eval and xpath_eval_expr maapi methods, and I seem to get slightly different results.

In cases where my xpath query should return multiple values, with xpath_eval I can see all matching nodes, but when I use xpath_eval_expr, the return value contains only the first xpath expression that matches the query.

Is that expected behavior?

Am I missing something obvious?

Thanks,

Yftach

(NSO 4.5.2)

For example:

u = "/aaa/authentication/users/user/name"

def foo(x,y):

     print('x = {}'.format(x))

     print('y = {}'.format(y))

maapi.xpath_eval(sock_maapi, th, u, foo, None, '/')

x = /aaa:aaa/authentication/users/user{admin}/name

y = admin

x = /aaa:aaa/authentication/users/user{oper}/name

y = oper

x = /aaa:aaa/authentication/users/user{private}/name

y = private

x = /aaa:aaa/authentication/users/user{public}/name

y = public

print(maapi.xpath_eval_expr(sock_maapi, th, u, None, '/'))

admin