Hi Mansi,

let $cmd := "/A/*/descendant::C/descandant::*[contains(@name,'"|| $n ||"')]”

Just a quick scan - I marked the problem in <bold> above - I would try ‘descendant’
instead of 'descandant’.

Cheers,
Lukas