This is implementation dependent, so it cannot be generalized to all XML databases. Although in this simple case, I think it is the same for all databases: it does not matter.
BaseX, . , , <A/>. , XPath,
:
db:text("your-database", "John")/parent::*:Name/parent::*:A
XPath , , :
//A[Name/@n = "John"]
db:attribute("your-database", "John")/self::*:n/parent::*:Name/parent::*:A
, ( ), , db:text() vs. db:attribute(). , , ( ), .
, XML XQuery, , . , .