Find element in xml-tree

@ is for attributes; for a text node test, use text(),

//lens/code/[@text()="7041"]
             ^

and also remove the spurious / ahead of the predicate:

//lens/code/[text()="7041"]
           ^

to get this XPath expression,

//lens/code[text()="7041"]

will select all of the code element children of lens elements, provided the code element has a text() text node child with a string value of "7041".

You could also test the string value of code,

//lens/code[.="7041"]

If you actually want to select lens elements, elevate the predicate:

//lens[code="7041"]

See also

  • Testing text() nodes vs string values in XPath

Thanks to Mads Hansen for correcting a glaring mistake in a previous version of this answer.